AD
Administrator
Syncfusion Team
June 20, 2006 03:32 PM UTC
Hi Dhans,
Try this code to set the font of the cell in a grid. Here is a code snippet.
this.gridControl1.TableStyle.Text = "welcome";
//For all cells in a Grid.
this.gridControl1.TableStyle.Font = new GridFontInfo(new Font("Arial",10f));
//For a second row cells in a Grid.
this.gridControl1.RowStyles[2].Font = new GridFontInfo(new Font("Arial",12f));
//For a first column cells in a Grid.
this.gridControl1.ColStyles[1].Font = new GridFontInfo(new Font("Times New Roman",15f));
//For a particular cell(2,1) in a Grid.
this.gridControl1[2,1].Font = new GridFontInfo(new Font("Tahoma",18f));
Please refer to the Browser sample for StyleObject precedent.
\Syncfusion\Essential Studio\4.2.0.37\windows\Grid.Windows\Samples\Quick Start\GridStyleInfoAtWork
Let me know if this helps.
Best Regards,
Haneef
AD
Administrator
Syncfusion Team
June 21, 2006 04:57 AM UTC
Thanks Haneef,
But if i do set the font through
this.gridControl1.TableStyle.Font = new GridFontInfo(new Font("Arial",10f));
The font of the Row & Column Headers are not changing
Regards,
Dhans
AD
Administrator
Syncfusion Team
June 21, 2006 04:34 PM UTC
Hi Dhans,
Try this code for setting the font in a header cell of the grid. Here is a code snippet
//For all Headers in a grid.
this.gridControl1.BaseStylesMap["Header"].StyleInfo.Font = new GridFontInfo(new Font("Arial",10f));
//For Row Header in a grid
this.gridControl1.BaseStylesMap["Row Header"].StyleInfo.Font = new GridFontInfo(new Font("Arial",10f));
//For Column Header in a Grid.
this.gridControl1.BaseStylesMap["Column Header"].StyleInfo.Font = new GridFontInfo(new Font("Arial",10f));
Let me know if this helps.
Best Regards,
Haneef
AD
Administrator
Syncfusion Team
June 22, 2006 04:54 AM UTC
Basically what i need is, user can configure the font of the gridcontrol from the application. The grid may have the Data in the resource(.resx) files, If user change the font from the form, then it should change all the fonts in the grid control(including Header,TextBox and ComboBox etc cells). Can you give me a sample for that?
I got the exception, when i try to set the fone for Header cells.
Font font = new Font("Arial", 10f, gridControl1.Font.Style);
this.gridControl1.Font = font;
this.gridControl1.BaseStylesMap["Header"].StyleInfo.Font = new GridFontInfo(font);
Here is the exception:
System.NullReferenceException: Object reference not set to an instance of an object.
at Syncfusion.Styles.StyleInfoStore.get_IsEmpty()
at Syncfusion.Styles.StyleInfoBase.get_IsEmpty()
at Syncfusion.Styles.StyleInfoIdentityBase.GetBaseStyleNotEmptyExpandable(IStyleInfo thisStyleInfo, StyleInfoProperty sip)
at Syncfusion.Windows.Forms.Grid.GridStyleInfo.get_GdipFont()
at Syncfusion.Windows.Forms.Grid.GridStaticCellModel.OnQueryPrefferedClientSize(Graphics g, Int32 rowIndex, Int32 colIndex, GridStyleInfo style, GridQueryBounds queryBounds)
at Syncfusion.Windows.Forms.Grid.GridHeaderCellModel.OnQueryPrefferedClientSize(Graphics g, Int32 rowIndex, Int32 colIndex, GridStyleInfo style, GridQueryBounds queryBounds)
at Syncfusion.Windows.Forms.Grid.GridCellModelBase.CalculatePreferredCellSize(Graphics g, Int32 rowIndex, Int32 colIndex, GridStyleInfo style, GridQueryBounds queryBounds)
at Syncfusion.Windows.Forms.Grid.GridModelColWidthsIndexer.ResizeToFit(GridRangeInfo range, GridResizeToFitOptions options)
AD
Administrator
Syncfusion Team
June 22, 2006 03:13 PM UTC
Hi Dhans,
I have tested this issue by creating a sample using GridControl in v.4.1 and then again tested by upgrading to 4.2. I was not able to reproduce the issue. Maybe I am not following the steps that you are doing. Attached sample working fine here. If you can provide more information, we can try to suggest some solution.
Here is a sample
http://www.syncfusion.com/Support/user/uploads/gridcontrol_ca67d8f1.zip
Could you please run this at your end and let me know how it goes?
Thanks for your patience.
Best Regards,
Haneef
AD
Administrator
Syncfusion Team
June 23, 2006 05:21 AM UTC
Thanks haneef,
I am not having Sync v4.x. I have mentioned that I am using Sync v2.0.5.1 and .NET 1.1. Can you do the sample in 2.0.5.1 and .NET 1.1?
Thanks,
Dhans
AD
Administrator
Syncfusion Team
June 23, 2006 09:13 PM UTC
Hi Dhans,
Try setting the font of the header cell in prepareviewStyleInfo event. Here is a code snippet.
private void gridControl1_PrepareViewStyleInfo(object sender, Syncfusion.Windows.Forms.Grid.GridPrepareViewStyleInfoEventArgs e)
{
if( e.RowIndex == 0 || e.ColIndex == 0)
{
e.Style.Font = new GridFontInfo(new Font("Arial",20f));
}
}
Let me know if this helps.
Best Regards,
Haneef
AD
Administrator
Syncfusion Team
June 29, 2006 12:43 PM UTC
I have attached a sample to set the font of the grid control( Sync V 2.0.5.1 and .NET 1.1).
In this I have handled the PrepareViewStyle event to set the font for each cell. Select the "Arial Block" and "12" from the combo box, these font will be set by clicking the "Set Font" button. The font is set correctly, but the grid doesn''t resize according to new font (I have called the ResizeToFit method for both ColWidth and RowHeight.
SyncGridFont0.zip
AD
Administrator
Syncfusion Team
June 29, 2006 03:09 PM UTC
Hi Dhans,
The reason is that you are using the PrepareViewStyleinfo event. PrepareviewStyleInfo event does not store any styleInfo properties in a grid. It just set the visual apperence of the grid. ResizeToFit method resizes a range of rows or columns to optimally fit stored contents of the specified range of cells in grid. It depends on the data stored in a grid. If the Grid doesn''''t have any data, ResizeToFit method doesn''''t make any changes in a Grid. Here is a code snippet.
private void gridControl_QueryCellInfo(object sender, Syncfusion.Windows.Forms.Grid.GridQueryCellInfoEventArgs e)
{
if(font != null)
e.Style.Font = new GridFontInfo(font);
}
Please let me know if this helps.
Best Regards,
Haneef
AD
Administrator
Syncfusion Team
June 30, 2006 07:26 AM UTC
Thanks Haneef,
Is there any way that i can change the font of Syncfusion.Windows.Forms.Tools.XPMenus.Bar control?
Regards,
Dhans
MJ
Mano J
Syncfusion Team
June 30, 2006 09:53 PM UTC
Hi Dhans,
It is not possible to change the font in v.2.0.5.1. If you upgrade to v.4.X, you can set the font through MainFrameBarManager''s font property or every BarItem''s CustomTextFont property.
Thanks,
Mano
AD
Administrator
Syncfusion Team
July 3, 2006 10:47 AM UTC
But the size of the XPMenus.Bar is increases if i change the font of the form which contains this Bar. Can i prevent the bar from changing its size?
MJ
Mano J
Syncfusion Team
July 3, 2006 07:53 PM UTC
Hi Dhans,
I have tested this font issue in v.2.0.5.1. But I dont see font changing for the BarItems when the form''s font is changed.
Can you please upload the sample that shows this issue?
Best Regards,
Mano
AD
Administrator
Syncfusion Team
July 4, 2006 03:41 AM UTC
The font for the BarItems are not changing. The width of the Bar is increasing, if i change the font of the form which contains the Bar.
Regards,
Dhans
AD
Administrator
Syncfusion Team
July 4, 2006 08:27 AM UTC
>The font for the BarItems are not changing. The width of the Bar is increasing, if i change the font of the form which contains the Bar.
This is happening only when the size of the font of the Form is increasing.
>
>Regards,
>Dhans
NI
Niranjan
replied to Administrator
February 23, 2018 01:03 PM UTC
Hi Dhans,
I have tested this issue by creating a sample using GridControl in v.4.1 and then again tested by upgrading to 4.2. I was not able to reproduce the issue. Maybe I am not following the steps that you are doing. Attached sample working fine here. If you can provide more information, we can try to suggest some solution.
Here is a sample
http://www.syncfusion.com/Support/user/uploads/gridcontrol_ca67d8f1.zip
Could you please run this at your end and let me know how it goes?
Thanks for your patience.
Best Regards,
Haneef
Yes
AR
Arulpriya Ramalingam
Syncfusion Team
February 25, 2018 10:23 AM UTC
Hi Niranjan,
Thanks for your update.
Please let us know, if you have any other queries.
Regards,
Arulpriya