GridMenuEventArgs.MenuType Property
Gets the context menu’s type.
Namespace: DevExpress.Xpf.Grid
Assembly: DevExpress.Xpf.Grid.v20.1.Core.dll
NuGet Packages: DevExpress.WindowsDesktop.Wpf.Grid.Core, DevExpress.Wpf.Grid.Core
Declaration
Property Value
Type | Description |
---|---|
Nullable<GridMenuType> | A GridMenuType enumeration value that identifies the context menu. |
Available values:
Name | Description |
---|---|
Column | Corresponds to a menu invoked for a column header. |
TotalSummary | Corresponds to a menu invoked for the Summary Panel. |
RowCell | Corresponds to a menu invoked for the Row Cell. |
GroupPanel | Corresponds to a menu invoked for the group panel. |
FixedTotalSummary | Corresponds to a menu invoked for the Fixed Summary Panel. |
Band | Corresponds to a menu invoked for a band. |
GroupFooterSummary | Corresponds to a menu invoked for the Group Footer‘s summary. |
GroupRow | Corresponds to a menu invoked for the group row. |
FixRowControl | Corresponds to a menu invoked for a fix row button. |
CompactPanelSortElement | Corresponds to a menu invoked for sort items in compact panel. |
CompactPanelFilter | Corresponds to a menu invoked for a compact panel filter. |
CompactPanelMergeMenu | Corresponds to a merged menu invoked for a filter and sort items in compact panel. |
Remarks
To learn more, see Context Menus.
Example
The following example demonstrates how to customize the grid’s context menu at runtime. This sample removes the default Show Column Chooser menu item from the Column Context Menu and adds a custom item instead.
Handle the DataViewBase.ShowGridMenu event. In the event handler, change the GridMenuEventArgs.Customizations collection to modify the list of menu items. To remove a menu item with its link, use the RemoveBarItemAndLinkAction instance. To add a custom menu item, add a new BarButtonItem object to the GridMenuEventArgs.Customizations collection.
Note
A complete sample project is available at https://github.com/DevExpress-Examples/how-to-modify-the-context-menu-of-grid-columns-e1837.
<dxg:GridControl.View>
<dxg:TableView ShowGridMenu="TableView_ShowGridMenu" />
</dxg:GridControl.View>
private void TableView_ShowGridMenu(object sender, GridMenuEventArgs e) {
// Check whether this event was raised for a column's context menu.
if (e.MenuType != GridMenuType.Column) return;
// Remove the Column Chooser menu item.
e.Customizations.Add(new RemoveBarItemAndLinkAction() {
ItemName = DefaultColumnMenuItemNames.ColumnChooser });
// Create a custom menu item and add it to the context menu.
BarButtonItem bi = new BarButtonItem();
bi.Name = "customItem";
bi.Content = "Custom Item";
bi.ItemClick += new ItemClickEventHandler(customItem_ItemClick);
e.Customizations.Add(bi);
}
private void customItem_ItemClick(object sender, ItemClickEventArgs e) {
// Implement the custom action.
// ...
}
Related GitHub Examples
The following code snippets (auto-collected from DevExpress Examples) contain references to the MenuType property.
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.