Category / Section
How to retrieve all records of grouped column when double clicking on it in WinForms GridGroupingControl?
2 mins read
Records of grouped column
To get the records of grouped columns by double-clicking in GGC, the event gridGroupingControl1_TableControlCellDoubleClick can be used. Using GridTableCellStyleInfo the table records details can be fetched.
This is done by the double click event, which gets the rowIndex and columnIndex of the records of the grouped columns using GridTableControlCellClickEventArgs and can be displayed via a MessageBox dialog.
C#
//Form() this.gridGroupingControl1.TableControlCellDoubleClick += gridGroupingControl1_TableControlCellDoubleClick; void gridGroupingControl1_TableControlCellDoubleClick(object sender, GridTableControlCellClickEventArgs e) { GridTableCellStyleInfo style = e.TableControl.GetTableViewStyleInfo(e.Inner.RowIndex, e.Inner.ColIndex); Element el = style.TableCellIdentity.DisplayElement; if (el != null) { string s = ""; foreach (Record rec in el.ParentGroup.Records) { //Retrieves the Records of the parent group s += rec.ToString() + Environment.NewLine; } //Shows the Content in the MessageBox MessageBox.Show(s,"Info"); } }
VB
'Form() Me.gridGroupingControl1.TableControlCellDoubleClick += gridGroupingControl1_TableControlCellDoubleClick Private Sub gridGroupingControl1_TableControlCellDoubleClick(ByVal sender As Object, ByVal e As GridTableControlCellClickEventArgs) Dim style As GridTableCellStyleInfo = e.TableControl.GetTableViewStyleInfo(e.Inner.RowIndex, e.Inner.ColIndex) Dim el As Element = style.TableCellIdentity.DisplayElement If el IsNot Nothing Then Dim s As String = "" For Each rec As Record In el.ParentGroup.Records 'Retrieves the Records of the parent group s &= rec.ToString() & Environment.NewLine Next rec 'Shows the Content in the MessageBox MessageBox.Show(s,"Info") End If End Sub
Samples:
C#: ChildGroup_CS
VB: ChildGroup_VB