A group is a collection of data rows that are combined automatically by matching field values or according to user-specified criteria. Groups are represented by the Group class. Grids created using Xceed Grid for WinForms can contain an unlimited number of nested group levels.
Data bound rows can be grouped automatically or manually. To do automatic grouping, the GroupBy property of a group must be set to the field name of the column in the grid by which the data rows are to be grouped. To group the data rows manually, the QueryGroupKeys event can be used. This event can be used in conjunction with the GroupBy property to provide additional custom grouping criteria.
Groups by themselves do not have a visual representation. In order for groups to have a visual representation, they usually contain at least one row that is not a data row in their header or footer sections. Typically, a GroupManagerRow is added to the header rows of a group to create an Outlook style grid.
The example below demonstrates 2 ways in which groups can be created and added to the grid's collection of group templates:
C# | Copy Code |
---|---|
|
Groups can be accessed via the Groups property of both the GridControl class (which represents the grid) and the Group class (which represents a group). For example:
The way in which the grid is grouped can be changed by modifying the group templates via the grid's GroupTemplates property. If the group templates are modified, the UpdateGrouping method must be called in order for the changes to be reflected in the grid.
Do you want to provide custom grouping? Jump to the Custom Grouping topic.