Skip to main content

How to: Add and Remove Items From Filter Drop-Down Lists

  • 2 minutes to read

The following example shows how to add and remove items from the filter dropdown list.In this example, the 'Beverages' item is hidden from the filter dropdown list of the Category field, and a dummy item is created and added to the list. To do this, the CustomFilterPopupItems event is handled. In the event handler, the 'Beverages' item is removed from the event parameter's Items collection, and a new item ('Dummy Item') is added to the collection.

View Example

using System.Windows;
using DevExpress.Xpf.PivotGrid;
using DevExpress.XtraPivotGrid.Data;
using DXPivotGrid_CustomFilterItems.DataSet1TableAdapters;

namespace DXPivotGrid_CustomFilterItems {
    public partial class MainWindow : Window {
        DataSet1.ProductReportsDataTable productReportsDataTable =
            new DataSet1.ProductReportsDataTable();
        ProductReportsTableAdapter productReportsDataAdapter = new ProductReportsTableAdapter();
        public MainWindow() {
            pivotGridControl1.DataSource = productReportsDataAdapter.GetData();
        readonly string dummyItem = "";
        private void pivotGridControl1_CustomFilterPopupItems(object sender,
                                    PivotCustomFilterPopupItemsEventArgs e) {
            if (object.ReferenceEquals(e.Field, fieldCategoryName)) {
                for (int i = e.Items.Count - 1; i >= 0; i--) {
                    if (object.Equals(e.Items[i].Value, "Beverages")) {
                e.Items.Insert(0, new PivotGridFilterItem(dummyItem,
                                                          "Dummy Item",