Skip to main content
A newer version of this page is available. .

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.