DefaultColumnMenuItemNames Class

Contains default item captions displayed within the column context menu.

Namespace: DevExpress.Xpf.Grid

Assembly: DevExpress.Xpf.Grid.v20.1.dll

Declaration

public class DefaultColumnMenuItemNames :
    DefaultColumnMenuItemNamesBase
Public Class DefaultColumnMenuItemNames
    Inherits DefaultColumnMenuItemNamesBase

Remarks

Refer to the How to: Localize a Grid by Replacing Specific Strings at Runtime example for information on how to change default menu item captions.

Examples

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.

<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.
    // ...
}

Inheritance

Object
DefaultColumnMenuItemNamesBase
DefaultColumnMenuItemNames
See Also