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.v24.2.dll
NuGet Package: DevExpress.Win.Navigation
#Declaration
#Event Data
The CustomizeSearchMenu event's data class is RibbonSearchMenuEventArgs. The following properties provide information specific to this event:
Property | Description |
---|---|
Menu | Gets the search menu. |
Search |
Gets text entered in the search box.
Inherited from Ribbon |
Show |
Gets or sets whether to display the No matches found item in the Search Menu. |
The event data class exposes the following methods:
Method | Description |
---|---|
Add |
Adds a header to the Search Menu. |
Add |
Adds an item to the Search Menu. |
#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. - AddHeader(String) – Adds a header to the search menu.
- AddItem(BarItem) – Adds an item to the search menu.
- ShowNoMatchesItem – Specifies whether to display the No matches found item.
Enable the RibbonOptionsSearchMenu.UseCustomRibbonSearch option to populate the search menu only through the CustomizeSearchMenu
event.
#Example
The code below shows how to add a custom button to the menu and 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.AddItem(ShareButton);
// Show the Online Help command regardless of the current query.
e.Menu.ItemLinks.Where(x => x.Item == biOnlineHelp).First().Visible = true;
}