How to: Customize a RibbonControl's Customization Menu

  • 2 minutes to read

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);
    }
}