Articles in this section

How to highlight the expanded records which are all having the nested table in WinForms GridGroupingControl?

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 the 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 

The screenshot below illustrates the highlighting of expanded records in GridGroupingControl.

Highlight the expanded records in WinForms


Samples:

C#: Highlight Expanded Records CS 

VB: Highlight Expanded Records VB

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Access denied
Access denied