RadControls for WinForms

When a group is created it is added to the Groups collection of the corresponding template. You can access the groups collection in the following way:

Copy[C#] Accessing groups
DataGroupCollection templateGroupCollection = this.radGridView1.MasterTemplate.Groups;
Copy[VB.NET] Accessing groups
Dim templateGroupCollection = Me.RadGridView1.MasterTemplate.Groups

You can expand and collapse groups programmatically. The code blocks below demonstrate how you can expand and collapse the first group in the Groups collection.

Copy[C#] Expanding groups
this.radGridView1.Groups[0].Expand();
Copy[VB.NET] Expanding groups
Me.RadGridView1.Groups(0).Expand()
Copy[C#] Collapse groups
this.radGridView1.Groups[0].Collapse();
Copy[VB.NET] Collapse groups
Me.RadGridView1.Groups(0).Collapse()

You can use AllowGroup property of each column to indicate whether the user will be able to group by this column or not. The default value is true.

Copy[C#] Allow groups
this.radGridView1.Columns["Country"].AllowGroup = false;
Copy[VB.NET] Allow groups
Me.RadGridView1.Columns("Country").AllowGroup = False

DataGroup class

DataGroup collections have hierarchical structure. One or more group levels could be created. Properties of the DataGroup give access to its Level, Parent and Child groups:

Copy[C#] Accessing parent/child groups
int groupLevel= this.radGridView1.Groups[0].Level;
Group<GridViewRowInfo> parentGroup = this.radGridView1.Groups[0].Parent;
DataGroupCollection groups = this.radGridView1.Groups[0].Groups;
Copy[VB.NET] Accessing parent/child groups
Dim groupLevel As Integer = Me.RadGridView1.Groups(0).Level
Dim parentGroup As Group(Of GridViewRowInfo) = Me.RadGridView1.Groups(0).Parent
Dim groups As DataGroupCollection = Me.RadGridView1.Groups(0).Groups
The header row of a group (GridViewGroupRowInfo) can be accessed using the GroupRow property for a particular data group, for example:
Copy[C#] Accessing group header row
GridViewRowInfo groupHeaderRow = radGridView1.Groups[0].GroupRow;
Copy[VB.NET] Accessing group header row
Dim groupHeaderRow = Me.RadGridView1.Groups(0).GroupRow