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

colors in grouping grid

Hi, Is it possible to use different color for different grouping levels in a grouping grid. I use a caption summary grid, and if i have 3 grouping (summary) levels, each level has the same color. The actual record cells have a different color though. For example if i have a grid with Country , State , city and city population, if i add country and state as grouped cols, and summarize city population, I will get country total and state totals in the same color. I need this to be a bit different. Any help would be great.

2 Replies

AD Administrator Syncfusion Team July 5, 2005 11:34 PM UTC

So you have summaries in the group caption row? If so, you can try using QueryCellStyleInfo to color the different levels. Here is code that colors level 1.
private void gridGroupingControl1_QueryCellStyleInfo(object sender, GridTableCellStyleInfoEventArgs e)
{
	if(e.TableCellIdentity.TableCellType == GridTableCellType.GroupCaptionSummaryCell)
	{
		GridCaptionRow caption = e.TableCellIdentity.DisplayElement as GridCaptionRow;
		if(caption.ParentGroup.GroupLevel == 1)
			e.Style.BackColor = Color.LightGoldenrodYellow;
	}
}


AD Administrator Syncfusion Team July 6, 2005 08:01 PM UTC

You can also modify the color for individual grouping levels if you change GridColumnDescriptor.GroupByAppearance. For example, if you grouped by "Country" and "Region", you can change the formatting with
grid.TableDescriptor.Columns["Country"].GroupByAppearance.GroupCaptionCell.BackColor = Color.Green;
grid.TableDescriptor.Columns["Region"].GroupByAppearance.GroupCaptionCell.BackColor = Color.Blue;
Stefan >So you have summaries in the group caption row? If so, you can try using QueryCellStyleInfo to color the different levels. Here is code that colors level 1. >
>private void gridGroupingControl1_QueryCellStyleInfo(object sender, GridTableCellStyleInfoEventArgs e)
>{
>	if(e.TableCellIdentity.TableCellType == GridTableCellType.GroupCaptionSummaryCell)
>	{
>		GridCaptionRow caption = e.TableCellIdentity.DisplayElement as GridCaptionRow;
>		if(caption.ParentGroup.GroupLevel == 1)
>			e.Style.BackColor = Color.LightGoldenrodYellow;
>	}
>}
>
>

Loader.
Live Chat Icon For mobile
Up arrow icon