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.
Unfortunately, activation email could not send to your email. Please try again.

How do I iterate through groups in a GridGroupingControl?

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.

C#

VB

 

Figure 1: GridGroupingControl

 

Figure 2: Screenshot of the output

Sample Link:

C#: IterateGroups

VB: IterateGroups

Article ID: Published Date: Last Revised Date: Platform: Control:
593 04/30/2011 04/20/2015 Windows Forms GridGroupingControl
Tags:
Did you find this information helpful?
Comments
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.

Reply
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



Else




GroupStatus = 2



End If




listGroupStatus.Add(GroupStatus)



End If




g_prev = g



Next


End Function


Reply
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?

Reply
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.

https://www.syncfusion.com/account/login

Regards,

Piruthiviraj


Add Comment
You must log in to leave a comment

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.