RibbonControl.ExpandCollapseMenuShowing Event
Allows you to customize the Ribbon menu or prevent it from being displayed based on a condition.
Namespace: DevExpress.XtraBars.Ribbon
Assembly: DevExpress.XtraBars.v24.2.dll
Declaration
[DXCategory("Events")]
public event ExpandCollapseMenuShowingEventHandler ExpandCollapseMenuShowing
Event Data
The ExpandCollapseMenuShowing event's data class is ExpandCollapseMenuShowingEventArgs. The following properties provide information specific to this event:
Property | Description |
---|---|
Allow | Gets or sets whether to display a popup menu. |
Menu | Gets a popup menu. |
Remarks
If the OptionsExpandCollapseMenu.EnableExpandCollapseMenu option is enabled, the Ribbon control displays a popup menu with display options after a user has clicked the Ribbon Display Options button.
The Ribbon control raises the ExpandCollapseMenuShowing
event before the menu is displayed. Handle this event to customize the menu or prevent it from being displayed.
Use the e.Menu property to obtain the popup menu.
Set the e.Allow property to DefaultBoolean.False
to prevent the menu from being displayed.
using DevExpress.Utils;
using DevExpress.XtraBars.Ribbon;
private void Form1_Load(object sender, EventArgs e) {
EnableRibbonExpandCollapseMenu();
}
void EnableRibbonExpandCollapseMenu() {
ribbonControl1.OptionsExpandCollapseMenu.EnableExpandCollapseMenu = DefaultBoolean.True;
ribbonControl1.OptionsExpandCollapseMenu.ShowRibbonLayoutGroup = DefaultBoolean.True;
ribbonControl1.ExpandCollapseMenuShowing += RibbonControl1_ExpandCollapseMenuShowing;
}
private void RibbonControl1_ExpandCollapseMenuShowing(object sender, ExpandCollapseMenuShowingEventArgs e) {
// Use 'e.Menu' to add new menu items aor customize the existing menu items.
// e.Menu.AddItem(barItem);
// e.Menu.ItemLinks[0].Caption = "CUSTOM_CAPTION";
// Prevents the menu from being displayed.
// e.Allow = false;
}
The following screenshot shows the result: