How to modify appearance of only certain header cells?

I have a GridControl (v5.102.0.51) for which I have set two fixed column header rows, like so:

mygrid.Rows.HeaderCount = 2
mygrid.Rows.FrozenCount = 2

I want to change the style of the second header row but nothing I try seems to work. I've tried modifying mygrid.RowStyles(1), but the changes don't seem to stick.

What is the proper way to modify the appearance of individual header cells/rows?


2 Replies

AD Administrator Syncfusion Team April 1, 2008 10:48 PM UTC

HiDon,

Thank you for your interest in Syncfusion products.

You need to handle PrepareViewStyleInfo event to set the style of the row in a GridControl. Please refer the below sample code for more details.


void gridControl1_PrepareViewStyleInfo(object sender, Syncfusion.Windows.Forms.Grid.GridPrepareViewStyleInfoEventArgs e)
{
if (e.RowIndex > 2 && e.RowIndex < 5)
{
e.Style.BackColor = Color.Cornsilk;
}
else if (e.RowIndex > 5 && e.RowIndex < 10)
{
e.Style.BackColor = Color.Gold;
}

}


Please let me know if this helps.

Best Regards,
Srirajan





DO Don April 2, 2008 10:12 AM UTC

Ah, that should do it. I was messing around with the PrepareViewStyleInfo event, but I was always getting stack overflows because I was setting the style property of the grid directly instead of using the Style member of the 'e' parameter. Silly me.


Loader.
Up arrow icon