Skip to main content

PivotGridControl.GetColumnIndex(Object[], PivotGridField) Method

Returns the index of the specified column.

Namespace: DevExpress.XtraPivotGrid

Assembly: DevExpress.XtraPivotGrid.v24.1.dll

NuGet Package: DevExpress.Win.PivotGrid

Declaration

public int GetColumnIndex(
    object[] values,
    PivotGridField field
)

Parameters

Name Type Description
values Object[]

An array of column field values that identify the column.

field PivotGridField

A PivotGridField object that is the Data Field whose values are displayed in 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:

GetColumnIndex

The field parameter allows you to specify the Data Field if the pivot grid displays data for several fields.

The following table demonstrates how to get indices for different columns.

C# Visual Basic Return Value
pivotGridControl.GetColumnIndex(new object[] {2018}, fieldQuantity) pivotGridControl.GetColumnIndex(New Object() {2018}, fieldQuantity) 0
pivotGridControl.GetColumnIndex(new object[] {2018}, fieldExtendedPrice) pivotGridControl.GetColumnIndex(New Object() {2018}, fieldExtendedPrice) 1
pivotGridControl.GetColumnIndex(new object[] {2019, 8, “UK”}, fieldQuantity) pivotGridControl.GetColumnIndex(New Object() {2019, 8, “UK”}, fieldQuantity) 2
pivotGridControl.GetColumnIndex(new object[] {2019, 8, “UK”}, fieldExtendedPrice) pivotGridControl.GetColumnIndex(New Object() {2019, 8, “UK”}, fieldExtendedPrice) 3
pivotGridControl.GetColumnIndex(new object[] {2019, 8, “USA”}, fieldQuantity); pivotGridControl.GetColumnIndex(New Object() {2019, 8, “USA”}, fieldQuantity) 4
pivotGridControl.GetColumnIndex(new object[] {2019, 8, “USA”}, fieldExtendedPrice) pivotGridControl.GetColumnIndex(New Object() {2019, 8, “USA”}, fieldExtendedPrice) 5
pivotGridControl.GetColumnIndex(new object[] {2019, 8}, fieldQuantity) pivotGridControl.GetColumnIndex(New Object() {2019, 8}, fieldQuantity) 6
pivotGridControl.GetColumnIndex(new object[] {2019, 8}, fieldExtendedPrice) pivotGridControl.GetColumnIndex(New Object() {2019, 8}, fieldExtendedPrice) 7
pivotGridControl.GetColumnIndex(new object[] {}, fieldQuantity); pivotGridControl.GetColumnIndex(New Object() {}, fieldQuantity) 8
pivotGridControl.GetColumnIndex(new object[] {}, fieldExtendedPrice); pivotGridControl.GetColumnIndex(New Object() {}, fieldExtendedPrice) 9

Note that 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.

See Also