GridControl.ContextMenuOpening Event
In This Article
Occurs before a user opens a context menu.
Namespace: DevExpress.WinUI.Grid
Assembly: DevExpress.WinUI.Grid.v23.2.dll
NuGet Package: DevExpress.WinUI
#Declaration
public event EventHandler<ContextMenuOpeningEventArgs> ContextMenuOpening
#Event Data
The ContextMenuOpening event's data class is DevExpress.WinUI.Core.Internal.ContextMenuOpeningEventArgs.
#Remarks
The ContextMenuOpening event allows you to customize the default context menu. The ContextMenuOpeningEventArgs.Info property returns information about the context menu.
The following code sample adds the Show Search Panel and Hide Search Panel items to the group panel‘s context menu:
<dxg:GridControl ...
ShowGroupPanel="True"
ContextMenuOpening="grid_ContextMenuOpening">
<!-- ... -->
</dxg:GridControl>
void grid_ContextMenuOpening(object sender, DevExpress.WinUI.Core.Internal.ContextMenuOpeningEventArgs e) {
var menuInfo = e.Info as GridGroupPanelContextMenuInfo;
if (menuInfo != null) {
var contextMenu = menuInfo.MenuContent;
contextMenu.Items.Add(new MenuFlyoutSeparator());
contextMenu.Items.Add(new MenuFlyoutItem() {Text = "Show Search Panel", Command = menuInfo.Commands.ShowSearchPanel});
contextMenu.Items.Add(new MenuFlyoutItem() {Text = "Hide Search Panel", Command = menuInfo.Commands.HideSearchPanel});
}
}
See Also