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 apply the conditional formats to the cell using GridConditionalFormatDescriptor in WinForms GridGroupingControl?

Platform: WinForms |
Control: GridGroupingControl

Conditional formatting

By default, the conditional format will be set to the entire row. In order to set the ConditionalFormatting for a particular cell at run time, GridConditionalFormatDescriptor and QueryCellInfo event can be used. In QueryCellInfo event, the CompareRecord() method can be used to compare the records with condition.


GridConditionalFormatDescriptor descriptor = new GridConditionalFormatDescriptor();
//To add the condition
descriptor.Expression = "[CategoryID]>50";
//Event Triggering
this.gridGroupingControl1.QueryCellStyleInfo += GridGroupingControl1_QueryCellStyleInfo;
//Event Customization
private void GridGroupingControl1_QueryCellStyleInfo(object sender, GridTableCellStyleInfoEventArgs e)
    if (e.TableCellIdentity.Column != null && e.TableCellIdentity.Column.Name == "Description" && e.TableCellIdentity.DisplayElement.Kind == DisplayElementKind.Record)
        Record record = e.TableCellIdentity.DisplayElement.GetRecord();
        if (descriptor.CompareRecord(record))
            e.Style.BackColor = Color.Yellow;



Private descriptor As New GridConditionalFormatDescriptor()
'To add the condition
 descriptor.Expression = "[CategoryID]>50"
'Event Triggering
AddHandler Me.gridGroupingControl1.QueryCellStyleInfo, AddressOf GridGroupingControl1_QueryCellStyleInfo
'Event Customization
Private Sub GridGroupingControl1_QueryCellStyleInfo(ByVal sender As Object, ByVal e As GridTableCellStyleInfoEventArgs)
    If e.TableCellIdentity.Column IsNot Nothing AndAlso e.TableCellIdentity.Column.Name = "Description" AndAlso e.TableCellIdentity.DisplayElement.Kind = DisplayElementKind.Record Then
        Dim record As Record = e.TableCellIdentity.DisplayElement.GetRecord()
        If descriptor.CompareRecord(record) Then
            e.Style.BackColor = Color.Yellow
        End If
    End If
End Sub



Applied conditional formats to the cell


C#: Conditional_Formatting_CS

VB: Conditional_Formatting_VB

Reference link: https://help.syncfusion.com/windowsforms/classic/gridgroupingcontrol/conditional-formatting

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