Skip to main content
A newer version of this page is available. .

FilterControl.PopupMenuShowing Event

Fires when a popup menu is about to be displayed for the FilterControl’s visual elements.

Namespace: DevExpress.XtraEditors

Assembly: DevExpress.XtraEditors.v18.2.dll

Declaration

[DXCategory("Events")]
public event PopupMenuShowingEventHandler PopupMenuShowing

Event Data

The PopupMenuShowing event's data class is PopupMenuShowingEventArgs. The following properties provide information specific to this event:

Property Description
Cancel Gets or sets a value indicating whether the event should be canceled. Inherited from CancelEventArgs.
CurrentNode Gets the node where the menu is to be displayed.
FocusedElementType Gets the type of the Filter Control’s element where the menu is to be displayed.
Menu Gets the menu that will be invoked.
MenuType Gets the type of the FilterControl’s menu to be invoked.
Point Gets the position where the menu is to be invoked.
RestoreMenu Gets or sets whether the current menu should be restored to its default state, after it has been displayed on-screen.

Remarks

When handling this event, you can use the event’s parameters to identify the clicked element, and the type of menu to be invoked. It’s possible to access and modify the menu, if required.

Using the event’s Cancel parameter, you can prevent the menu from being displayed.

Example

The following code shows how to remove the NOT AND and NOT OR operators from a FilterControl when the FilterControl is used in an Grid Control. These operators are removed via the FilterControl.PopupMenuShowing event. When a FilterControl is used within an Grid Control, you can access the FilterControl and subscribe to the FilterControl.PopupMenuShowing event by handling the ColumnView.FilterEditorCreated event.

using System;
using System.Data;
using System.Windows.Forms;
using DevExpress.XtraEditors.Controls;
using DevExpress.XtraEditors.Filtering;

namespace Q101293 {
    public partial class Form1 : Form {
        public Form1() {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e) {
            DataTable tbl = new DataTable();
            tbl.Columns.Add("ID", typeof(int));
            tbl.Columns.Add("Name", typeof(string));
            tbl.Columns.Add("Check", typeof(bool));
            for(int i = 1; i < 10; i++)
                tbl.Rows.Add(i, string.Format("Item {0}", i), i % 2 == 0);
            gridControl1.DataSource = tbl;
            gridView1.ActiveFilterString = "[Check] = false";
        }

        private void gridView1_FilterEditorCreated(object sender, DevExpress.XtraGrid.Views.Base.FilterControlEventArgs e) {
            e.FilterControl.PopupMenuShowing += OnFilterControlPopupMenuShowing;
        }

        void OnFilterControlPopupMenuShowing(object sender, PopupMenuShowingEventArgs e) {
            if (e.MenuType == FilterControlMenuType.Group) {
                for (int i = e.Menu.Items.Count - 1; i >= 0; i--) {
                    if (e.Menu.Items[i].Caption == Localizer.Active.GetLocalizedString(StringId.FilterGroupNotAnd) ||
                        e.Menu.Items[i].Caption == Localizer.Active.GetLocalizedString(StringId.FilterGroupNotOr)) {
                        e.Menu.Items.RemoveAt(i);
                    }
                }
            }
        }
    }
}

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the PopupMenuShowing event.

Note

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