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
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to avoid selection backcolor for particular cells in WinForms GridGroupingControl?

Platform: WinForms |
Control: GridGroupingControl

Avoid select the backcolor

By default, the SelectionBackColor will override the BackColor of the cell. In order to avoid SelectionBackColor override the BackColor of the cell, the TableControlDrawCellDisplayText event can be used to draw the color on the cell.


//Triggering the event.
this.gridGroupingControl1.TableControlDrawCellDisplayText += new GridTableControlDrawCellDisplayTextEventHandler(gridGroupingControl1_TableControlDrawCellDisplayText);
//Event Customization.
void gridGroupingControl1_TableControlDrawCellDisplayText(object sender, GridTableControlDrawCellDisplayTextEventArgs e)
    GridTableCellStyleInfo style = e.Inner.Style as GridTableCellStyleInfo;
    if (style.TableCellIdentity != null && style.TableCellIdentity.Column != null &&
        style.TableCellIdentity.Column.Name == "Description" && e.Inner.RowIndex == 5)
        Rectangle rectangle = e.Inner.ClipBounds;
        rectangle.X -= 1;
        rectangle.Y -= 1;
        rectangle.Height += 3;
        rectangle.Width += 2;
        e.Inner.Graphics.FillRectangle(new SolidBrush(Color.LightBlue), rectangle);



'Triggering the event.
AddHandler gridGroupingControl1.TableControlDrawCellDisplayText, AddressOf gridGroupingControl1_TableControlDrawCellDisplayText
'Event Customization.
Private Sub gridGroupingControl1_TableControlDrawCellDisplayText(ByVal sender As Object, ByVal e As GridTableControlDrawCellDisplayTextEventArgs)
    Dim style As GridTableCellStyleInfo = TryCast(e.Inner.Style, GridTableCellStyleInfo)
    If style.TableCellIdentity IsNot Nothing AndAlso style.TableCellIdentity.Column IsNot Nothing AndAlso style.TableCellIdentity.Column.Name = "Description" AndAlso e.Inner.RowIndex = 5 Then
        Dim rectangle As Rectangle = e.Inner.ClipBounds
        rectangle.X -= 1
        rectangle.Y -= 1
        rectangle.Height += 3
        rectangle.Width += 2
        e.Inner.Graphics.FillRectangle(New SolidBrush(Color.LightBlue), rectangle)
    End If
End Sub



Avoiding selection backcolor for particular cells



C#: Selection CS

VB: Selection VB

2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
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