Skip to main content
All docs
V26.1
  • 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.v26.1.dll

    NuGet Package: DevExpress.Win.Navigation

    Declaration

    [DXCategory("Events")]
    public event RibbonSearchMenuEventHandler CustomizeSearchMenu

    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.
    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.

    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:

    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;
    }
    
    See Also