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

RibbonControl.ShowCustomizationMenu Event

Occurs before the RibbonControl’s Customization Menu is displayed.

Namespace: DevExpress.XtraBars.Ribbon

Assembly: DevExpress.XtraBars.v19.1.dll

Declaration

[DXCategory("Events")]
public event RibbonCustomizationMenuEventHandler ShowCustomizationMenu

Event Data

The ShowCustomizationMenu event's data class is DevExpress.XtraBars.Ribbon.RibbonCustomizationMenuEventArgs.

Remarks

The Customization Menu is displayed when a Ribbon Control is right-clicked. You can handle the ShowCustomizationMenu event to customize the menu or prevent it from being displayed.

The customization menu is not recreated each time it needs to be displayed. Therefore, if the menu has been modified in the ShowCustomizationMenu event handler, the changes will persist the next time the ShowCustomizationMenu event fires. So, before modifying the menu, you generally need to check whether modifications have been already made or not.

Example

The following example demonstrates how to customize a RibbonControl’s Customization Menu. The RibbonControl.ShowCustomizationMenu event is handled to add a custom About menu item.

The result is illustrated below:

RibbonControl.ShowCustomizationMenu_Ex

using DevExpress.XtraBars;
using DevExpress.XtraBars.Ribbon;

// The item to be added to the Customization Menu
BarItem biAbout;
// Initialize the item and add it to the RibbonControl's item collection.
private void Form1_Load(object sender, EventArgs e) {
    biAbout = new BarButtonItem();
    biAbout.Caption = "About";
    biAbout.ItemClick += new ItemClickEventHandler(biAbout_ItemClick);
    RibbonControl1.Items.Add(biAbout);
}
// The method invoked when the item is clicked.
void biAbout_ItemClick(object sender, ItemClickEventArgs e) {
    MessageBox.Show("About");
}

BarItemLink biAboutLink = null;
// Add the item to the Customization Menu.
private void RibbonControl1_ShowCustomizationMenu(object sender, 
  RibbonCustomizationMenuEventArgs e) {
    if (biAboutLink == null) {
        biAboutLink = e.CustomizationMenu.AddItem(biAbout);
    }
}
See Also