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. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Styling Group Header

Thread ID:

Created:

Updated:

Platform:

Replies:

150375 Jan 4,2020 01:55 AM UTC Jan 6,2020 01:14 PM UTC WinForms 1
loading
Tags: SfDataGrid
Mariusz Juszkiewicz
Asked On January 4, 2020 01:55 AM UTC

I would like to display different color for different level of grouping.

Saravanan Ayyanar [Syncfusion]
Replied On January 6, 2020 01:14 PM UTC

Hi Mariusz Juszkiewicz, 
 
Thank you for using Syncfusion control. 
 
You can achieve your requirement to display the different color for different level of grouping by using the sfDataGrid.QueryRowStyle event. Please refer the below code snippet, 
 
this.sfDataGrid.QueryRowStyle += SfDataGrid_QueryRowStyle; 
 
private void SfDataGrid_QueryRowStyle(object sender, QueryRowStyleEventArgs e) 
{ 
    if (e.RowType == RowType.CaptionRow || e.RowType == RowType.CaptionCoveredRow) 
    { 
        var groupLevel = (e.RowData as Group).Level; 
        if (groupLevel == 1) 
            e.Style.BackColor = Color.Red; 
        else if (groupLevel == 2) 
            e.Style.BackColor = Color.Bisque; 
        else if (groupLevel == 3) 
            e.Style.BackColor = Color.Blue; 
        else if (groupLevel == 4) 
            e.Style.BackColor = Color.Yellow; 
    } 
} 
 
 
Sample Link: 
 
Please let us know, if you require further assistance on this.   
   
Regards,   
Saravanan A. 


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.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon 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.Close Icon

Live Chat Icon For mobile
Live Chat Icon