Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

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.v24.2.Core.dll

NuGet Package: DevExpress.Wpf.Grid.Core

#Declaration

[Browsable(false)]
public BarManagerActionCollection ColumnMenuCustomizations { get; }

#Property Value

Type Description
BarManagerActionCollection

A collection of bar actions to customize the column header‘s context menu.

#Remarks

Refer to the Context Menus topic for more information.

#Example

The following example demonstrates how to add a custom menu item to a grid column’s context menu:

Grid - Add Items to the Context Menu

View Example: Customize the GridControl's Context Menu

#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 Content="Checked" IsChecked="True" dxb:BarItemLinkActionBase.ItemLinkIndex="0"/>
    <dxb:BarItemLinkSeparator dxb:BarItemLinkActionBase.ItemLinkIndex="1"/>
</dxg:TableView.ColumnMenuCustomizations>

#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);
    }
}
See Also