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.

How to modify appearance of only certain header cells?

Thread ID:

Created:

Updated:

Platform:

Replies:

72716 Apr 1,2008 02:37 PM Apr 2,2008 06:12 AM Windows Forms 2
loading
Tags: GridControl
Don
Asked On April 1, 2008 02:37 PM

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?


Administrator [Syncfusion]
Replied On April 1, 2008 06:48 PM

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




Don
Replied On April 2, 2008 06:12 AM

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.


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.

;