windowsforms-devexpress-dot-xtrabars-dot-ribbon-dot-ribboncontrol-22416473.md
Fires when the query in the search box changes and allows you to customize search results.
Namespace : DevExpress.XtraBars.Ribbon
Assembly : DevExpress.XtraBars.v25.2.dll
NuGet Package : DevExpress.Win.Navigation
[DXCategory("Events")]
public event RibbonSearchMenuEventHandler CustomizeSearchMenu
<DXCategory("Events")>
Public Event CustomizeSearchMenu As RibbonSearchMenuEventHandler
The CustomizeSearchMenu event's data class is RibbonSearchMenuEventArgs. The following properties provide information specific to this event:
| Property | Description |
|---|---|
| Menu | Gets the search menu. |
| SearchString | Gets text entered in the search box. Inherited from RibbonSearchMenuBaseEventArgs. |
| ShowNoMatchesItem | 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 |
|---|---|
| AddHeader(String) | Adds a header to the Search Menu. |
| AddItem(BarItem) | Adds an item to the Search Menu. |
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:
Menu.ItemLinks collection contains all the available bar item links. An item link is visible or hidden based on the current search query.Enable the RibbonOptionsSearchMenu.UseCustomRibbonSearch option to populate the search menu only through the CustomizeSearchMenu event.
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;
}
Imports DevExpress.XtraBars
Private shareButton1 As BarButtonItem
Private ReadOnly Property ShareButton() As BarButtonItem
Get
If shareButton1 Is Nothing Then
Dim share As New BarButtonItem()
share.Caption = "Share"
AddHandler share.ItemClick, Sub(s, e) MessageBox.Show("Share")
shareButton1.Manager = ribbonControl1.Manager
Me.shareButton1 = share
End If
Return shareButton1
End Get
End Property
Private Sub ribbonControl1_CustomizeSearchMenu(ByVal sender As Object, ByVal e As Ribbon.RibbonSearchMenuEventArgs) _
Handles ribbonControl1.CustomizeSearchMenu
' 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(Function(x) x.Item Is biOnlineHelp).First().Visible = True
End Sub
See Also