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: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How do I iterate through groups in a GridGroupingControl?

Platform: WinForms |
Control: GridGroupingControl |
Published Date: April 30, 2011 |
Last Revised Date: April 20, 2015
Tags: grouping

Under a group, there may be either records or sub-groups. A group has two properties, group.Groups and group.Records. When the parent group contains records, then group.Records can be accessed, and when the parent group contains child groups, you can iterate through the group.Groups collection. This can be achieved using a simple recursive function.




Figure 1: GridGroupingControl


Figure 2: Screenshot of the output

Sample Link:

C#: IterateGroups

VB: IterateGroups

2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
You must log in to leave a comment
Burkhard Morgeneyer
Nov 08, 2017

I don't have a toplevel group where all other groups are inside.

I have a number flat hirachical groups (e.g. 10) and below are no groups.

Now I want to iterate trough all groups, but not recursively.

I want to store each group status for later restoring the status after loading new data.

Burkhard Morgeneyer
Nov 08, 2017

Private Function GetGroupStatus(dgv As GridGroupingControl) As List(Of Integer)

Dim listGroupStatus As New List(Of Integer)

For Each r As Record In dgv.Table.Records

Dim g As Group = r.ParentGroup

Dim g_prev As Group

If g_prev IsNot Nothing AndAlso g IsNot g_prev Then

Dim GroupStatus As Integer

If g.IsExpanded Then

GroupStatus = 1


GroupStatus = 2

End If


End If

g_prev = g


End Function

Burkhard Morgeneyer
Nov 08, 2017

But before code only works, if there are records in the group. If the group is empty, the code doesnt work.

Where do I find the collection of groups?

Piruthiviraj Malaimelraj [Syncfusion]
Nov 08, 2017

Hi Burkhard,

Thanks for your update.

We could understand your requirements and we request you to create the new ticket for your requirements, it would be better to provide the solution for your exact requirements and to followup with your queries.




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