Skip to main content

PivotCustomFieldValueCellsEventArgs.Remove(FieldValueCell) Method

Removes the specified field value cell.

Namespace: DevExpress.Xpf.PivotGrid

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

NuGet Package: DevExpress.Wpf.PivotGrid


public bool Remove(
    FieldValueCell item


Name Type Description
item FieldValueCell

A FieldValueCell object that represents the field value cell to remove.


Type Description

true if the specified cell has been found and removed; false if the specified cell has not been found.


To locate the required field value cell, use the PivotCustomFieldValueCellsEventArgs.GetCell or PivotCustomFieldValueCellsEventArgs.FindCell method.

Note that if a field value cell has only one child cell, and this child cell is removed via the Remove method, the parent cell is then automatically removed.


The following example demonstrates how handle the CustomFieldValueCells event to hide specific rows and columns. 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

The following code snippets (auto-collected from DevExpress Examples) contain references to the Remove(FieldValueCell) method.


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.

See Also