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

How to get caption section of each group level

Hi,

I need to apply different color to the different group levels. How to get the caption section of each lower group level.

How to apply different colour to different lower group section in grid grouping control.

Please help

2 Replies

AD Administrator Syncfusion Team January 29, 2007 07:28 PM UTC

Hi Harshad,

How to apply different colour to different lower group section in grid grouping control?

>>>>>
If you want to set the back color of the group based on column name than you can use the GridColumnDescriptorr.GroupByAppearance property. Here is a code snippet to show this.

this.gridGroupingControl1.TableDescriptor.Columns[0].GroupByAppearance.AnyCell.BackColor = Color.Pink;

If you want to set the back color of the group based on group level then you can handle the TableControlPrepareViewStyleInfo event and set the e.Inner.Style.BackColor property to new color to want to display.

//C# code.
private void gridGroupingControl1_TableControlPrepareViewStyleInfo(object sender, GridTableControlPrepareViewStyleInfoEventArgs e)
{
GridTableCellStyleInfo style = e.Inner.Style as GridTableCellStyleInfo;
Element el = style.TableCellIdentity.DisplayElement as Element;

if( el.ParentGroup != null )
{
switch( el.ParentGroup.GroupLevel )
{
case 0:
e.Inner.Style.BackColor = Color.Red;
break;
case 1:
e.Inner.Style.BackColor = Color.Green;
break;
case 2:
e.Inner.Style.BackColor = Color.Blue;
break;
case 3:
e.Inner.Style.BackColor = Color.Yellow;
break;
default :
e.Inner.Style.BackColor = Color.WhiteSmoke;
break;
}
}
}

How to get the caption section of each lower group level?

>>>
Try this code in

GridCaptionSection caption = el.ParentGroup.Groups[0].Caption as GridCaptionSection;

Best Regards,
Haneef


AD Administrator Syncfusion Team January 30, 2007 10:24 AM UTC

Thanks a lot...

Its working fine

Loader.
Live Chat Icon For mobile
Up arrow icon