Skip to main content

PivotCustomFieldValueCellsEventArgs.GetCell(Boolean, Int32) Method

Returns the field value cell by its index.

Namespace: DevExpress.Xpf.PivotGrid

Assembly: DevExpress.Xpf.PivotGrid.v22.1.dll


public FieldValueCell GetCell(
    bool isColumn,
    int index


Name Type Description
isColumn Boolean

true to obtain the column field value cell; false to obtain the row field value cell.

index Int32

An integer value that specifies the zero-based index of the cell.


Type Description

A FieldValueCell object that represents the required cell; null if the index is out of bounds.


Field value cells are indexed in the order shown in the image below:


The field value cell can be also located via the PivotCustomFieldValueCellsEventArgs.FindCell method that returns the cell whose column/row summary values match the specified condition.


The following example demonstrates how to hide particular rows and columns by handling the CustomFieldValueCells event.In this example, the event handler iterates through all row headers and removes rows that correspond to the "Employee B" field value, and that are not Total Rows.

View Example

Imports Microsoft.VisualBasic
Imports System.Globalization
Imports System.Windows
Imports DevExpress.Xpf.PivotGrid

Namespace DXPivotGrid_HidingColumnsAndRows
    Partial Public Class Window1
        Inherits Window
        Public Sub New()
            AddHandler pivotGrid.CustomFieldValueCells, AddressOf pivotGrid_CustomFieldValueCells
        End Sub
        Private Sub Window_Loaded(ByVal sender As Object, ByVal e As RoutedEventArgs)
            pivotGrid.DataSource = PivotHelper.GetDataTable()
        End Sub

        ' Handles the CustomFieldValueCells event to remove
        ' specific rows.
        Private Sub pivotGrid_CustomFieldValueCells(ByVal sender As Object, _
                                                    ByVal e As PivotCustomFieldValueCellsEventArgs)
            If pivotGrid.DataSource Is Nothing Then
            End If
            If rbDefault.IsChecked = True Then
            End If

            ' Iterates through all row headers.
            For i As Integer = e.GetCellCount(False) - 1 To 0 Step -1
                Dim cell As FieldValueCell = e.GetCell(False, i)
                If cell Is Nothing Then Continue For

                ' If the current header corresponds to the "Employee B"
                ' field value, and is not the Total Row header,
                ' it is removed with all corresponding rows.
                If Object.Equals(cell.Value, "Employee B") AndAlso _
                        cell.ValueType <> FieldValueType.Total Then
                End If
            Next i
        End Sub
        Private Sub pivotGrid_FieldValueDisplayText(ByVal sender As Object, _
                                                    ByVal e As PivotFieldDisplayTextEventArgs)
            If Object.Equals(e.Field, pivotGrid.Fields(PivotHelper.Month)) Then
                e.DisplayText = _
            End If
        End Sub
        Private Sub rbDefault_Checked(ByVal sender As Object, ByVal e As RoutedEventArgs)
        End Sub
    End Class
End Namespace
See Also