Skip to main content

GridOptionsMenu.EnableGroupRowMenu Property

Gets or sets whether users can invoke a context menu with a right-click on a group row.

Namespace: DevExpress.XtraGrid.Views.Grid

Assembly: DevExpress.XtraGrid.v24.1.dll

NuGet Packages: DevExpress.Win.Grid, DevExpress.Win.Navigation

Declaration

[DefaultValue(false)]
[XtraSerializableProperty]
public virtual bool EnableGroupRowMenu { get; set; }

Property Value

Type Default Description
Boolean false

true if users can invoke a context menu with a right-click on a group row; otherwise, false.

Property Paths

You can access this nested property as listed below:

Object Type Path to EnableGroupRowMenu
GridView
.OptionsMenu .EnableGroupRowMenu

Remarks

If the GridView.OptionsMenu.EnableGroupRowMenu option is enabled, the grid view shows a context menu when a user right-clicks a group.

image

Predefined commands

The context menu contains the following predefined commands:

  • Collapse (Expand) — collapses (expands) the clicked group.
  • Full Collapse — collapses all groups.
  • Full Expand — expands all groups.

Localize the menu

The GridLocalizer allows you to localize the command captions. Use the MenuGroupRowCollapse, MenuGroupRowExpand, MenuGroupPanelFullExpand and MenuGroupPanelFullCollapse fields to identify the commands.

using DevExpress.XtraGrid.Localization;

GridLocalizer.Active = new GroupRowContextMenuLocalizer();

public class GroupRowContextMenuLocalizer : GridLocalizer {
    public override string Language { get { return "English"; } }
    public override string GetLocalizedString(GridStringId id) {
        switch (id) {
            case GridStringId.MenuGroupRowCollapse: return "Collapse this group";
            case GridStringId.MenuGroupRowExpand: return "Expand this groups";
            case GridStringId.MenuGroupPanelFullExpand: return "Expand all groups";
            case GridStringId.MenuGroupPanelFullCollapse: return "Collapse all nodes";
            default: return base.GetLocalizedString(id);
        }
    }
}

Populate the menu

You can handle the GridView.PopupMenuShowing event to populate the menu with custom items.

using DevExpress.XtraGrid.Localization;

gridView1.PopupMenuShowing += GridView1_PopupMenuShowing;

private void GridView1_PopupMenuShowing(object sender, DevExpress.XtraGrid.Views.Grid.PopupMenuShowingEventArgs e) {
    if (e.Menu is DevExpress.XtraGrid.Menu.GridViewGroupRowMenu) {
        DevExpress.Utils.Menu.DXMenuItem item = new DevExpress.Utils.Menu.DXMenuItem();
        item.Caption = "Item";
        item.Click += (ss, ee) => { MessageBox.Show("Item clicked"); };
        e.Menu.Items.Add(item);
        e.Allow = true;
    }
}
See Also