Back to Devexpress

RibbonControl.ExpandCollapseMenuShowing Event

windowsforms-devexpress-dot-xtrabars-dot-ribbon-dot-ribboncontrol-39452539.md

latest4.4 KB
Original Source

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.v25.2.dll

NuGet Package : DevExpress.Win.Navigation

Declaration

csharp
[DXCategory("Events")]
public event ExpandCollapseMenuShowingEventHandler ExpandCollapseMenuShowing
vb
<DXCategory("Events")>
Public Event ExpandCollapseMenuShowing As ExpandCollapseMenuShowingEventHandler

Event Data

The ExpandCollapseMenuShowing event's data class is ExpandCollapseMenuShowingEventArgs. The following properties provide information specific to this event:

PropertyDescription
AllowGets or sets whether to display a popup menu.
MenuGets 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.

csharp
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;
}
vb
Imports DevExpress.Utils
Imports DevExpress.XtraBars.Ribbon

Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs)
    EnableRibbonExpandCollapseMenu()
End Sub
Private Sub EnableRibbonExpandCollapseMenu()
    ribbonControl1.OptionsExpandCollapseMenu.EnableExpandCollapseMenu = DefaultBoolean.True
    ribbonControl1.OptionsExpandCollapseMenu.ShowRibbonLayoutGroup = DefaultBoolean.True
    AddHandler ribbonControl1.ExpandCollapseMenuShowing, AddressOf RibbonControl1_ExpandCollapseMenuShowing
End Sub
Private Sub RibbonControl1_ExpandCollapseMenuShowing(ByVal sender As Object, ByVal e As ExpandCollapseMenuShowingEventArgs)
    ' 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;
End Sub

The following screenshot shows the result:

See Also

OptionsExpandCollapseMenu

RibbonControl Class

RibbonControl Members

DevExpress.XtraBars.Ribbon Namespace