PivotGridControl.GetColumnIndex(Object[]) Method
Returns the index of the specified column.
Namespace: DevExpress.XtraPivotGrid
Assembly: DevExpress.XtraPivotGrid.v24.1.dll
NuGet Package: DevExpress.Win.PivotGrid
Declaration
Parameters
Name | Type | Description |
---|---|---|
values | Object[] | An array of column field values that identify the column. |
Returns
Type | Description |
---|---|
Int32 | An integer value that specifies the column index. -1 if the specified column has not been not found. |
Remarks
Pivot Grid columns are indexed as shown below:
If the field value array identifies several columns, the GetColumnIndex method returns the smallest index. To get the column related to another data field, use the GetColumnIndex(Object[], PivotGridField) method overload that allows you to specify a data field.
The following table demonstrates how to get indices for the columns related to the first data field - the “Quantity” column indices. To get an index of the column related to the “Ext Price” field, use the GetColumnIndex(Object[], PivotGridField) method.
C# | Visual Basic | Return Value |
---|---|---|
pivotGridControl.GetColumnIndex(new object[] {2018}) | pivotGridControl.GetColumnIndex(New Object() {2018}) | 0 |
pivotGridControl.GetColumnIndex(new object[] {2019, 8, “UK”}); | pivotGridControl.GetColumnIndex(New Object() {2019, 8, “UK”}) | 2 |
pivotGridControl.GetColumnIndex(new object[] {2019, 8, “USA”}); | pivotGridControl.GetColumnIndex(New Object() {2019, 8, “USA”}) | 4 |
pivotGridControl.GetColumnIndex(new object[] {2019, 8}); | pivotGridControl.GetColumnIndex(New Object() {2019, 8}) | 6 |
pivotGridControl.GetColumnIndex(new object[] {}); | pivotGridControl.GetColumnIndex(New Object() {}) | 8 |
Note that the the method requires the field values, which may be different from the displayed text. In the picture above, the DateTime field grouped by Month displays “August“ and has the value 8. The grand total columns has null values.
Tip
To display field values instead of automatically created and formatted strings, handle the FieldValueDisplayText event.