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. Image for the cookie policy date
close icon

Recommended way to change font facename

I need to apply a font to a range of cells. I''m starting out by just changing the font family (facename). I get a GridStyleInfoStoreTable, iterate through it and call store.SetValue(CellFontProperty, mygridfontinfo) on each item, and finish with calling gridmodel.SetCells(storetable). Unfortunately this doesn''t seem to work as I get a red exception cell and null reference exceptions logged. The above approach seems to work for back/fore color and cell value. Is there a correct way to change the facename while still using GridStyleInfoStore? Thanks.

1 Reply

AD Administrator Syncfusion Team January 19, 2006 01:32 PM UTC

Hi Jim, Instead of changing through SetValue, try using ModifyStyle method. Here is the code snippet. if (this.gridControl1.Data[i, j] != null) { // this.gridControl1.Data[i, j].SetValue(GridStyleInfoStore.FontProperty, "Arial"); style.Font.Facename = "Arial"; style.Font.Bold = true; this.gridControl1.Data[i, j].ModifyStyle(style.Store, StyleModifyType.ApplyNew); } Refer to the sample for details Let us know if you need further assistance. Regards, Madhan.

Forum_39825.zip

Loader.
Live Chat Icon For mobile
Up arrow icon