DataViewBase.ColumnMenuCustomizations Property
Allows you to customize the column header‘s context menu. You can add new menu items or remove existing items.
Namespace: DevExpress.Xpf.Grid
Assembly: DevExpress.Xpf.Grid.v19.2.Core.dll
Declaration
Property Value
Type | Description |
---|---|
BarManagerActionCollection | A collection of bar actions to customize the column header‘s context menu. |
Remarks
Example
The following example demonstrates how to add a custom menu item to a grid column’s context menu:
Note
A complete sample project is available at https://github.com/DevExpress-Examples/how-to-customize-a-grids-context-menu-e1925.
In XAML
Add a bar item (for example, BarCheckItem) to the DataViewBase.ColumnMenuCustomizations
collection and specify item properties. Attach the BarItemLinkActionBase.ItemLinkIndex property to this item to insert it into a specific position.
<dxg:TableView.ColumnMenuCustomizations>
<dxb:BarCheckItem Name="checkItem1" Content="Checked" IsChecked="True" dxb:BarItemLinkActionBase.ItemLinkIndex="0" />
<dxb:BarItemLinkSeparator dxb:BarItemLinkActionBase.ItemLinkIndex="1" />
</dxg:TableView.ColumnMenuCustomizations>
private void customItem1_CheckedChanged(object sender, ItemClickEventArgs e) {
// do something...
}
In Code
Handle the ShowGridMenu event.
<dxg:TableView ShowGridMenu="ShowGridMenu" />
void ShowGridMenu(object sender, GridMenuEventArgs e) {
if (e.MenuType == GridMenuType.Column) {
BarCheckItem item1 = new BarCheckItem { Content = "Checked", IsChecked = true };
BarItemLinkActionBase.SetItemLinkIndex(item1, 0);
e.Customizations.Add(item1);
BarItemLinkSeparator item2 = new BarItemLinkSeparator();
BarItemLinkActionBase.SetItemLinkIndex(item2, 1);
e.Customizations.Add(item2);
}
}
Refer to the Context Menus topic for more information.
Related GitHub Examples
The following code snippets (auto-collected from DevExpress Examples) contain references to the ColumnMenuCustomizations 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.