GridColumn.GroupIndex Property
Gets or sets the if the grid data are grouped by the given column, and what the group level is.
Namespace: DevExpress.XtraGrid.Columns
Assembly: DevExpress.XtraGrid.v22.1.dll
NuGet Package: DevExpress.Win.Grid
Declaration
[DefaultValue(-1)]
[DXCategory("Data")]
[XtraSerializablePropertyId(2)]
public int GroupIndex { get; set; }
Property Value
Type | Default | Description |
---|---|---|
Int32 | -1 | The column’s grouping level. -1 if the View is not grouped by this column’s values. |
Remarks
You can group data in Grid Views by an unlimited number of columns. To group data by the values of a given column, set the column’s GroupIndex property to a non-negative integer. If several columns participate in grouping, the GroupIndex property specifies the grouping level. If set to 0, the column is at the root grouping level. Note that changing the GroupIndex property value updates this property value for other columns involved in grouping.
Set the GroupIndex property to -1 to cancel grouping by the column’s values. To clear grouping completely, call the View’s GridView.ClearGrouping method.
As data are grouped by column values, the column is added to the ColumnView.GroupedColumns collection. The GroupIndex property value matches the column’s position within that collection.
The code sample below illustrates how to group grid data by two columns.
gridView1.Columns["productCategory"].GroupIndex = 1;
gridView1.Columns["productStatus"].GroupIndex = 2;
Note that you cannot use this property for columns that have not been added to a Data Grid yet.
Related GitHub Examples
The following code snippets (auto-collected from DevExpress Examples) contain references to the GroupIndex property.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.