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.v20.1.dll

Declaration

[DXCategory("Data")]
[DefaultValue(-1)]
[XtraSerializablePropertyId(2)]
public int GroupIndex { get; set; }
<DXCategory("Data")>
<DefaultValue(-1)>
<XtraSerializablePropertyId(2)>
Public Property GroupIndex As Integer

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.

GC_GroupIndex_After


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.

See Also