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 get the records that belong to a GroupCaptionSection in the WinForms GridGroupingControl?

Platform: WinForms |
Control: GridGroupingControl |
Published Date: April 30, 2011 |
Last Revised Date: February 13, 2020
Tags: grouping, records


To get the records of a particular GroupCaptionSection, you can handle the TableControlCellMouseDown event and loop through the records in that group. To run the sample, right-click any GroupCaptionCell of a group to retrieve the records that belong to that group.


//Hooks the TableControlCellMouseDown event in Form_Load
this.gridGroupingControl1.TableControlCellMouseDown += gridGroupingControl1_TableControlCellMouseDown;
void gridGroupingControl1_TableControlCellMouseDown(object sender, Syncfusion.Windows.Forms.Grid.Grouping.GridTableControlCellMouseEventArgs e)
   if(e.Inner.MouseEventArgs.Button == MouseButtons.Right)
      //Gets the style for the clicked cell
      GridTableCellStyleInfo style = e.TableControl.GetTableViewStyleInfo(e.Inner.RowIndex, e.Inner.ColIndex);
      Element el = style.TableCellIdentity.DisplayElement;
      GridCaptionRow gridCaptionRow = style.TableCellIdentity.DisplayElement as GridCaptionRow;
      if(gridCaptionRow != null)
         string s = "";
         foreach (Record rec in gridCaptionRow.GetCaptionSection().ParentGroup.Records)
            //Retrieves the Values from the Record 
            s += rec.GetValue("Name").ToString() + " " + rec.GetValue("WorkingBranch").ToString() + " " + Environment.NewLine;
         //Shows the Content in the MessageBox


'Hooks the TableControlCellMouseDown event in Form_Load
Me.gridGroupingControl1.TableControlCellMouseDown += gridGroupingControl1_TableControlCellMouseDown
Private Sub gridGroupingControl1_TableControlCellMouseDown(ByVal sender As Object, ByVal e As Syncfusion.Windows.Forms.Grid.Grouping.GridTableControlCellMouseEventArgs)
   If e.Inner.MouseEventArgs.Button = MouseButtons.Right Then
      'Gets the style for the clicked cell
      Dim style As GridTableCellStyleInfo = e.TableControl.GetTableViewStyleInfo(e.Inner.RowIndex, e.Inner.ColIndex)
      Dim el As Element = style.TableCellIdentity.DisplayElement
      Dim gridCaptionRow As GridCaptionRow = TryCast(style.TableCellIdentity.DisplayElement, GridCaptionRow)
      If gridCaptionRow IsNot Nothing Then
         Dim s As String = ""
         For Each rec As Record In gridCaptionRow.GetCaptionSection().ParentGroup.Records
   'Retrieves the Values from the Record 
   s &= rec.GetValue("Name").ToString() & " " & rec.GetValue("WorkingBranch").ToString() & " " & Environment.NewLine
         Next rec
         'Shows the Content in the MessageBox
      End If
   End If
End Sub

The following screenshot displays the Group Caption Records.

Show group caption records


C#: GetGroupCaptionRecords-C#.zip

VB: GetGroupCaptionRecords-VB.zip

2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
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