New to Telerik UI for WinFormsStart a free 30-day trial

Groups Collection

Updated over 6 months ago

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:

Accessing groups

C#
DataGroupCollection templateGroupCollection = this.radGridView1.MasterTemplate.Groups;

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

Expanding groups

C#
this.radGridView1.Groups[0].Expand();

Collapse groups

C#
this.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.

Allow groups

C#
this.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:

Accessing parent/child groups

C#
int groupLevel= this.radGridView1.Groups[0].Level;
Group<GridViewRowInfo> parentGroup = this.radGridView1.Groups[0].Parent;
DataGroupCollection groups = this.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:

Accessing group header row

C#
GridViewRowInfo groupHeaderRow = radGridView1.Groups[0].GroupRow;

See Also

In this article
DataGroup classSee Also
Not finding the help you need?
Contact Support