)
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 set backcolor for a cell in WinForms GridGroupingControl?

Platform: WinForms |
Control: GridGroupingControl |
Published Date: April 19, 2015 |
Last Revised Date: February 13, 2020
Tags: styling

Changing back color for a cell or row

You can change the back color of the cell or row or column by using QueryCellStyleInfo event. In GridGroupingControl, the table model is derived from the Base styles. So that it does’nt support the GridGroupingControl to set styles.

The following code example explains how to change the background color of the particular cell and row by using QueryCellStyleInfo Event.

C#

void gridGroupingControl1_QueryCellStyleInfo(object sender, GridTableCellStyleInfoEventArgs e)
{
    // Applies style for a particular cell.
    if (e.TableCellIdentity.RowIndex == 5 && e.TableCellIdentity.ColIndex==3)
    {
    // Sets back color for a particular cell.
    e.Style.BackColor = Color.Red;
    }
}
void gridGroupingControl1_QueryCellStyleInfo(object sender, GridTableCellStyleInfoEventArgs e)
{
    // Applies style for a particular Row.
    if (e.TableCellIdentity.RowIndex == 6)
    {
        e.Style.BackColor = Color.Cornsilk;
    }
}

VB

Private Sub gridGroupingControl1_QueryCellStyleInfo(ByVal sender As Object, ByVal e As GridTableCellStyleInfoEventArgs)
 ' Applies style for a particular cell.
 If e.TableCellIdentity.RowIndex = 5 AndAlso e.TableCellIdentity.ColIndex=3 Then
  ' Sets back  color for a particular cell.
  e.Style.BackColor = Color.Red
 End If
End Sub
Private Sub gridGroupingControl1_QueryCellStyleInfo(ByVal sender As Object, ByVal e As GridTableCellStyleInfoEventArgs)
 ' Applies style for a particular Row.
 If e.TableCellIdentity.RowIndex = 6 Then
  e.Style.BackColor = Color.Cornsilk
 End If
End Sub

To set back color for a particular column, you can use TableDescriptor property. Refer to the following code examples.

C#

//Applies style for a particular column.
this.gridGroupingControl1.TableDescriptor.Columns["Column3"].Appearance.AnyRecordFieldCell.BackColor = Color.LightSkyBlue;

 

VB

'Applies style for a particular column.
Private Me.gridGroupingControl1.TableDescriptor.Columns("Column3").Appearance.AnyRecordFieldCell.BackColor = Color.LightSkyBlue

 

The following screenshot displays the changing background color for a particular Row and column.

 

Show change the backcolor of row and cell

Samples:

C#: BackColor-C#

VB: BackColor-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