)
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

How to apply different styles for the specific column or row or cell in WinForms GridGroupingControl?

Platform: WinForms |
Control: GridGroupingControl |
Published Date: April 15, 2016 |
Last Revised Date: February 12, 2020

Styles settings

In GridGroupingControl, specific styles for individual row, column and cells can be specified by using the QueryStyleCellInfo event. This event can be used to get or set every style properties of the grid. Any specified criteria of a row or column or cell can be applied with the style values.

C#

// form ()
// Trigger the required event
this.gridGroupingControl1.QueryCellStyleInfo += new GridTableCellStyleInfoEventHandler(gridGroupingControl1_QueryCellStyleInfo);
 
void gridGroupingControl1_QueryCellStyleInfo(object sender, GridTableCellStyleInfoEventArgs e)
{
    // Sets a specified style for a row.
    if(e.TableCellIdentity.RowIndex == 7)
    {
       e.Style.BackColor = Color.PaleGreen;
    }
    // Sets a specified style for a column.
    if(e.TableCellIdentity.ColIndex == 3)
    {
       e.Style.TextColor = Color.Red;
       e.Style.CellValueType = typeof(Int32);
    }
    // Sets a specified style for a single cell.
    if(e.TableCellIdentity.RowIndex == 6 && e.TableCellIdentity.ColIndex == 2)
    { 
       e.Style.BackColor = Color.LightPink;
       e.Style.CellType = GridCellTypeName.ProgressBar;
    }
}

VB

' form () 
' Trigger the required event
AddHandler gridGroupingControl1.QueryCellStyleInfo, AddressOf gridGroupingControl1_QueryCellStyleInfo
 
Private Sub gridGroupingControl1_QueryCellStyleInfo(ByVal sender As Object, ByVal e As GridTableCellStyleInfoEventArgs)
   ' Sets a specified style for a row.
   If e.TableCellIdentity.RowIndex = 7 Then
       e.Style.BackColor = Color.PaleGreen
   End If
   ' Sets a specified style for a column.
   If e.TableCellIdentity.ColIndex = 3 Then
       e.Style.TextColor = Color.Red
       e.Style.CellValueType = GetType(Int32)
   End If
   ' Sets a specified style for a single cell.
   If e.TableCellIdentity.RowIndex = 6 AndAlso e.TableCellIdentity.ColIndex = 2 Then
       e.Style.BackColor = Color.LightPink
       e.Style.CellType = GridCellTypeName.ProgressBar
   End If
End Sub

Screenshot

Show the different style applied to GridGroupingControl

Samples:

C#: Styles_CS

VB: Styles_VB

2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

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

Up arrow icon

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