Back to Devexpress

DataViewBase.ColumnMenuCustomizations Property

wpf-devexpress-dot-xpf-dot-grid-dot-dataviewbase-69e0669b.md

latest4.8 KB
Original Source

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

NuGet Package : DevExpress.Wpf.Grid.Core

Declaration

csharp
[Browsable(false)]
public BarManagerActionCollection ColumnMenuCustomizations { get; }
vb
<Browsable(False)>
Public ReadOnly Property ColumnMenuCustomizations As BarManagerActionCollection

Property Value

TypeDescription
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:

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.

xaml
<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.

xaml
<dxg:TableView ShowGridMenu="ShowGridMenu"/>
csharp
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);
    }
}
vb
Sub ShowGridMenu(sender As Object, e As GridMenuEventArgs)
    If e.MenuType = GridMenuType.Column Then
        Dim item1 As BarCheckItem = New BarCheckItem() With {.Content = "Checked", .IsChecked = True}
        BarItemLinkActionBase.SetItemLinkIndex(item1, 0)
        e.Customizations.Add(item1)
        Dim item2 As BarItemLinkSeparator = New BarItemLinkSeparator()
        BarItemLinkActionBase.SetItemLinkIndex(item2, 1)
        e.Customizations.Add(item2)
    End If
End Sub

The following code snippet (auto-collected from DevExpress Examples) contains a reference 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.

how-to-customize-a-grids-context-menu-e1925/CS/Window1.xaml#L11

xml
<!--region #Add-->
<dxg:TableView.ColumnMenuCustomizations>
    <dxb:BarCheckItem Content="BarCheckItem" dxb:BarItemLinkActionBase.ItemLinkIndex="0" CheckedChanged="BarCheckItem_CheckedChanged"/>

See Also

DataViewBase Class

DataViewBase Members

DevExpress.Xpf.Grid Namespace