Articles in this section
Category / Section

How to highlight a GroupHeader section when the GroupHeader is clicked in WinForms GridGroupingControl?

1 min read

Highlight the group header

You can highlight a GroupHeader section when the group header is clicked by using TableControlCellClick event. You can check if the selection is a GroupCaptionCell and can highlight the GroupHeader.

C#

void gridGroupingControl1_TableControlCellClick(object sender, GridTableControlCellClickEventArgs e)
{
   GridTableCellStyleInfo style = e.TableControl.Model[e.Inner.RowIndex, e.Inner.ColIndex];
   if(style.TableCellIdentity.TableCellType == GridTableCellType.GroupCaptionCell)
   {
      e.TableControl.Selections.Add(GridRangeInfo.Row(e.Inner.RowIndex));
      Console.WriteLine("Header clicked");
   }
}

VB

Private Sub gridGroupingControl1_TableControlCellClick(ByVal sender As Object, ByVal e As GridTableControlCellClickEventArgs)
   Dim style As GridTableCellStyleInfo = e.TableControl.Model(e.Inner.RowIndex, e.Inner.ColIndex)
   If style.TableCellIdentity.TableCellType = GridTableCellType.GroupCaptionCell Then
      e.TableControl.Selections.Add(GridRangeInfo.Row(e.Inner.RowIndex))
      Console.WriteLine("Header clicked")
   End If
End Sub

Screenshot

Highlight the group header

Samples:

C#: GroupHeader-C#

VB: GroupHeader-VB

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