GridControl.ContextMenuOpening Event

Occurs before the context menu is opened.

Namespace: DevExpress.UI.Xaml.Grid

Assembly: DevExpress.UI.Xaml.Grid.v20.1.dll


public event EventHandler<ContextMenuOpeningEventArgs> ContextMenuOpening
Public Event ContextMenuOpening As EventHandler(Of ContextMenuOpeningEventArgs)

Event Data

The ContextMenuOpening event's data class is DevExpress.UI.Xaml.ContextMenuOpeningEventArgs.


Use this event if you want to add custom items to the default context menu. The event's Info property returns an object that stores the menu settings. The below snippets illustrate how you can add custom menu items to the default context menu shown for GridControl columns:

private void GridControl_ContextMenuOpening(object sender, DevExpress.UI.Xaml.ContextMenuOpeningEventArgs e)
    var menuInfo = e.Info as GridColumnContextMenuInfo;
    if(menuInfo != null)
        var toolbar = menuInfo.MenuContent as ContextToolbarControl;
        toolbar.Group.Items.Add(new ContextToolbarButton() { Content = "Clear Filtering", Command = menuInfo.Commands.ClearFilter });
        toolbar.Group.Items.Add(new ContextToolbarButton() { Content = "Clear Grouping", Command = menuInfo.Commands.ClearGrouping });
See Also