Xceed Grid for WinForms v4.3 Documentation
Automatic grouping
Welcome to Xceed Grid for WinForms v4.3 > Task-Based Help > Grouping and sorting > Automatic grouping

Using the Grid Designer

When using the Grid Designer, groups can be added using either the GroupByRow or the Add group verb or menu.  The menu which is accessible by right-clicking on the body of the grid or on a group. 

Groups added using the Add group verb or menu are not yet configured. In order for the newly added group to actually group data rows, its GroupBy property must be set via the property grid. Groups added using the GroupByRow already have their GroupBy property set.

Using code

To automatically group the data in the grid, one or more Group objects must be created and added to the GroupTemplates property of the grid. Once the group is added, its GroupBy property needs to be set to the name of the field in the data source on which you want the data to be grouped. 

In order for a group to have an effective visual representation in the grid,   it must contain at least one specialized row in either its header or footer sections. The row most commonly used for this purpose is the GroupManagerRow

The following example demonstrates how to perform automatic grouping via code.   All data rows whose "ShipCountry" field contain the same value will be grouped together:

C# Copy Code

Group group = new Group();
group.GroupBy = "ShipCountry"; 

' Add a GroupManagerRow to the header section of the group in order  
' for the group to have an effective visual representation: 

group.HeaderRows.Add( new GroupManagerRow() );
gridControl1.GroupTemplates.Add( group );