All docs
V21.2
21.2
21.1
20.2
20.1
19.2
The page you are viewing does not exist in version 19.2. This link will take you to the root page.
19.1
The page you are viewing does not exist in version 19.1. This link will take you to the root page.
18.2
The page you are viewing does not exist in version 18.2. This link will take you to the root page.
18.1
The page you are viewing does not exist in version 18.1. This link will take you to the root page.
17.2
The page you are viewing does not exist in version 17.2. This link will take you to the root page.

Context Menu

  • 2 minutes to read

The Property Grid can display a context menu. To invoke the menu, users can right-click a property or click a property marker (in Office View only). The menu contains the predefined Reset command that sets the property to its default value. You can also handle a dedicated event to add custom commands to the menu.

Use the PropertyGridControl.OptionsMenu property to access the EnableContextMenu option that allows you to disable the context menu.

Add Commands to Menu

To populate the menu with custom commands, handle the PopupMenuShowing event.

Property Grid Context Menu

using DevExpress.Utils.Menu;

DXMenuItem createDataBindingItem;
protected DXMenuItem CreateDataBindingItem {
    get {
        if (createDataBindingItem == null) {
            DXMenuItem item = new DXMenuItem("Create Data Binding...");
            item.Click += (s, ee) => MessageBox.Show("'Create Data Binding...' is clicked.");
            createDataBindingItem = item;
        }
        return createDataBindingItem;
    }
}
private void Grid_PopupMenuShowing(object sender, Events.PopupMenuShowingEventArgs e) {
    if(e.Row.Properties.FieldName == "Appearance.BackColor")
        e.Menu.Items.Add(CreateDataBindingItem);
}

Note

When a user clicks a property marker, the context menu contains commands added in PopupMenuShowing and RowBrickMenuShowing event handlers.