)
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 highlight the expanded records which are all having the nested table in WinForms GridGroupingControl?

Platform: WinForms |
Control: GridGroupingControl |
Published Date: January 6, 2017 |
Last Revised Date: December 24, 2019

Highlight the expanded records

In order to highlight the expanded records which are all having the nested table, the QueryCellStyleInfo event can be used. Records expansion state can be getting by IsExpanded property and HasNestedTables property used to determine if record has nested tables.

C#

//Triggering the event 
this.groupingGrid1.QueryCellStyleInfo += GroupingGrid1_QueryCellStyleInfo;

//Event customization.
private void GroupingGrid1_QueryCellStyleInfo(object sender, GridTableCellStyleInfoEventArgs e)
{
    if (e.TableCellIdentity != null)
    {
        Record record = e.TableCellIdentity.DisplayElement.GetRecord();
        if (record != null && record.IsExpanded && record.HasNestedTables && (e.Style.TableCellIdentity.TableCellType == GridTableCellType.RecordFieldCell || e.Style.TableCellIdentity.TableCellType == GridTableCellType.AlternateRecordFieldCell))
        {
            e.Style.BackColor = Color.LightBlue;
            e.Style.TextColor = Color.White;
        }
    }
}

 

VB

'Triggering the event 
AddHandler Me.groupingGrid1.QueryCellStyleInfo, AddressOf GroupingGrid1_QueryCellStyleInfo
 
'Event customization.
Private Sub GroupingGrid1_QueryCellStyleInfo(ByVal sender As Object, ByVal e As GridTableCellStyleInfoEventArgs)
    If e.TableCellIdentity IsNot Nothing Then
        Dim record As Record = e.TableCellIdentity.DisplayElement.GetRecord()
        If record IsNot Nothing AndAlso record.IsExpanded AndAlso record.HasNestedTables AndAlso (e.Style.TableCellIdentity.TableCellType = GridTableCellType.RecordFieldCell OrElse e.Style.TableCellIdentity.TableCellType = GridTableCellType.AlternateRecordFieldCell) Then
            e.Style.BackColor = Color.LightBlue
            e.Style.TextColor = Color.White
        End If
    End If
End Sub

 

Screenshot

Highlight the expanded records

Samples:

C#: Highlight Expanded Records CS 

VB: Highlight Expanded Records 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