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
Samples:
C#: GroupHeader-C#
VB: GroupHeader-VB