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

DXMenuItem.Tag Property

Gets or sets the data associated with the menu item.

Namespace: DevExpress.Utils.Menu

Assembly: DevExpress.Utils.v24.2.dll

NuGet Packages: DevExpress.Utils, DevExpress.Wpf.Core

#Declaration

public object Tag { get; set; }

#Property Value

Type Description
Object

An object that contains the information which is associated with the menu item.

#Remarks

You can use the Tag property to associate any data with a menu item and then use this data for instance in a DXMenuItem.Click event handler.

#Example

The following code sample creates a menu item that fixes the column to the left. This item is added to the column header’s context menu next to the Hide This Column item:

WinForms Grid - Add Items to Context Menus

void gridView1_PopupMenuShowing(object sender, PopupMenuShowingEventArgs e) {
    if (e.MenuType == GridMenuType.Column) {
        DXMenuItem item = new DXMenuItem("Fix/Unfix This Column", (s, args) => {
            GridColumn column = (s as DXMenuItem).Tag as GridColumn;
            if (column.Fixed == FixedStyle.Left)
                column.Fixed = FixedStyle.None;
            else column.Fixed = FixedStyle.Left;
        });
        item.Tag = e.HitInfo.Column;
        int index = e.Menu.Items.IndexOf(e.Menu.Find(GridStringId.MenuColumnRemoveColumn));
        e.Menu.Items.Insert(index + 1, item);
    }
}

The following code snippets (auto-collected from DevExpress Examples) contain references to the Tag 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.

See Also