Alternate the colour of the Group Headings

I'm using the Grid Grouping control on a flat table. Setting the grouping to be 3 columns within the table.

Is it possible to alternate the back colour of the group headings? Like the way you can with the rows?

Cheers

Ken


2 Replies

AD Administrator Syncfusion Team February 28, 2008 12:05 AM UTC

Hi Ken,

You can handle the QueryCellStyleInfo event and set the backcolor of the GroupCaptionCell. Below are the codes:

void gridGroupingControl1_QueryCellStyleInfo(object sender, GridTableCellStyleInfoEventArgs e)
{
Element el = e.TableCellIdentity.DisplayElement;
if (e.TableCellIdentity.DisplayElement.Kind == DisplayElementKind.Caption)
{
int i = el.GetRowIndex();
e.Style.Themed = false;
if( i %2 == 0)
e.Style.BackColor = Color.Red;
else
e.Style.BackColor = Color.Blue;
}
}

Best regards,
Haneef



KE Ken March 3, 2008 09:00 AM UTC

Thanks Haneef that worked. The only minor issue with it was that as I'm using the Office look & feel that is built in, the group header stays the same colour. However, the rows are now alternate colours and I can live with that.

Cheers
Ken


Loader.
Up arrow icon