windowsforms-devexpress-dot-xtragrid-dot-views-dot-grid-dot-gridoptionsmenu-2c55db53.md
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.v25.2.dll
NuGet Packages : DevExpress.Win.Grid, DevExpress.Win.Navigation
[DefaultValue(false)]
[XtraSerializableProperty]
public virtual bool EnableGroupRowMenu { get; set; }
<DefaultValue(False)>
<XtraSerializableProperty>
Public Overridable Property EnableGroupRowMenu As Boolean
| Type | Default | Description |
|---|---|---|
| Boolean | false |
true if users can invoke a context menu with a right-click on a group row; otherwise, false.
|
You can access this nested property as listed below:
| Object Type | Path to EnableGroupRowMenu |
|---|---|
| GridView |
.OptionsMenu .EnableGroupRowMenu
|
If the GridView.OptionsMenu.EnableGroupRowMenu option is enabled, the grid view shows a context menu when a user right-clicks a group.
The context menu contains the following predefined commands:
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);
}
}
}
Imports DevExpress.XtraGrid.Localization
GridLocalizer.Active = New GroupRowContextMenuLocalizer()
Public Class GroupRowContextMenuLocalizer
Inherits GridLocalizer
Public Overrides ReadOnly Property Language() As String
Get
Return "English"
End Get
End Property
Public Overrides Function GetLocalizedString(ByVal id As GridStringId) As String
Select Case 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"
Case Else
Return MyBase.GetLocalizedString(id)
End Select
End Function
End Class
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;
}
}
Imports DevExpress.XtraGrid.Localization
AddHandler gridView1.PopupMenuShowing, AddressOf GridView1_PopupMenuShowing
Private Sub GridView1_PopupMenuShowing(ByVal sender As Object, ByVal e As DevExpress.XtraGrid.Views.Grid.PopupMenuShowingEventArgs)
If TypeOf e.Menu Is DevExpress.XtraGrid.Menu.GridViewGroupRowMenu Then
Dim item As New DevExpress.Utils.Menu.DXMenuItem()
item.Caption = "Item"
AddHandler item.Click, Sub(ss, ee)
MessageBox.Show("Item clicked")
End Sub
e.Menu.Items.Add(item)
e.Allow = True
End If
End Sub
See Also