We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

change gridcontrol font programatically

Thread ID:

Created:

Updated:

Platform:

Replies:

45405 Jun 20,2006 06:20 AM Feb 25,2018 05:23 AM Windows Forms 17
loading
Tags: GridControl
Administrator [Syncfusion]
Asked On June 20, 2006 06:20 AM

I am using syncfusion 2.0.5.1 and .NET 1.1 version. How do i set the font Name and Size for the gridcontrol programatically? I need to set the font for each of the cell in the gridcontrol and resize(ColWidths and RowHeights) them according to the new font size? Regards, Dhans

Administrator [Syncfusion]
Replied On June 20, 2006 11:32 AM

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

Administrator [Syncfusion]
Replied On June 21, 2006 12:57 AM

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

Administrator [Syncfusion]
Replied On June 21, 2006 12:34 PM

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

Administrator [Syncfusion]
Replied On June 22, 2006 12:54 AM

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)

Administrator [Syncfusion]
Replied On June 22, 2006 11:13 AM

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

Administrator [Syncfusion]
Replied On June 23, 2006 01:21 AM

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

Administrator [Syncfusion]
Replied On June 23, 2006 05:13 PM

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

Administrator [Syncfusion]
Replied On June 29, 2006 08:43 AM

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

Administrator [Syncfusion]
Replied On June 29, 2006 11:09 AM

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

Administrator [Syncfusion]
Replied On June 30, 2006 03:26 AM

Thanks Haneef, Is there any way that i can change the font of Syncfusion.Windows.Forms.Tools.XPMenus.Bar control? Regards, Dhans

Mano J [Syncfusion]
Replied On June 30, 2006 05:53 PM

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

Administrator [Syncfusion]
Replied On July 3, 2006 06:47 AM

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?

Mano J [Syncfusion]
Replied On July 3, 2006 03:53 PM

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

Administrator [Syncfusion]
Replied On July 3, 2006 11:41 PM

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

Administrator [Syncfusion]
Replied On July 4, 2006 04:27 AM

>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

Niranjan
Replied On February 23, 2018 08:03 AM

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

Arulpriya Ramalingam [Syncfusion]
Replied On February 25, 2018 05:23 AM

Hi Niranjan, 
 
Thanks for your update. 
 
Please let us know, if you have any other queries. 
 
Regards, 
Arulpriya 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;