RibbonControl.CustomizeSearchMenu Event

Fires when the query in the search box changes, and allows you to customize search results.

Namespace: DevExpress.XtraBars.Ribbon

Assembly: DevExpress.XtraBars.v20.1.dll

Declaration

[DXCategory("Events")]
public event RibbonSearchMenuEventHandler CustomizeSearchMenu
<DXCategory("Events")>
Public Event CustomizeSearchMenu As RibbonSearchMenuEventHandler

Event Data

The CustomizeSearchMenu event's data class is DevExpress.XtraBars.Ribbon.RibbonSearchMenuEventArgs.

Remarks

The CustomizeSearchMenu event fires when the query in the search box changes and allows you to customize the menu. The following properties provide information specific to this event:

  • SearchString - gets the search query;
  • Menu - gets the search menu (see PopupMenu). The Menu.ItemLinks collection contains all the available bar item links. An item link is visible or hidden based on the current search query.

Examples

The code below shows how to add a custom button to the menu, show an item regardless of the current query.

using DevExpress.XtraBars;

ribbonControl1.CustomizeSearchMenu += RibbonControl1_CustomizeSearchMenu;

BarButtonItem shareButton;
BarButtonItem ShareButton {
    get {
        if (shareButton == null) {
            BarButtonItem shareButton = new BarButtonItem();
            shareButton.Caption = "Share";
            shareButton.ItemClick += (s, e) => MessageBox.Show("Share");
            shareButton.Manager = ribbonControl1.Manager;
            this.shareButton = shareButton;
        }
        return shareButton;
    }
}

private void ribbonControl1_CustomizeSearchMenu(object sender, DevExpress.XtraBars.Ribbon.RibbonSearchMenuEventArgs e) {
    // Add a custom button that is always visible.
    e.Menu.AddItem(ShareButton);
    // Show the Online Help command regardless of the current query.
    e.Menu.ItemLinks.Where(x => x.Item == biOnlineHelp).First().Visible = true;
}
See Also