I have a number of virtual grids where I would like to set the font for all the cells programatically. When I try the following code I get a runtime exception:
this.vgTests.BaseStylesMap["Standard"].StyleInfo.Font = new GridFontInfo(font);
There seems to be a number of places to specify fonts when using a virtual grid in the designer. Please advise as to the best way to change manipulate grid fonts from code.
ADAdministrator Syncfusion Team May 29, 2005 09:03 PM
Try code like:
Font f = new Font("Courier", 14, FontStyle.Bold|FontStyle.Italic);
this.gridControl1.BaseStylesMap["Standard"].StyleInfo.Font.ModifyStyle(new GridFontInfo(f), Syncfusion.Styles.StyleModifyType.Changes);
KLKen LawJune 8, 2005 06:48 PM
I put your code sample in the constructor of the control that hosts the GridControl so it runs after InitializeComponent. InitializeComponent contains the following code for the GridControl''s font property generated by the Property Browser. The font property code seems to take precedence over setting the Standard style in the BaseStylesMap.
Can you tell me the relationship between the grid''s font property and the styles? I would like to be able to control the font of row and column headers independently of the cell fonts.
ADAdministrator Syncfusion Team June 8, 2005 08:19 PM
>>I would like to be able to control the font of row and column headers independently of the cell fonts.
The row and column styles (fonts) are controlled by grid.baseStylesMap["Row Header"].StyleInfo.Font and grid.baseStylesMap["Column Header"].StyleInfo.Font. Th etop-left cell is controlled by grid.baseStylesMap["Header"].StyleInfo.Font.