Skip to main content
All docs
V24.2

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

RibbonControl.SearchMenuEnterPressed Event

Occurs when a user presses Enter in the search box.

Namespace: DevExpress.XtraBars.Ribbon

Assembly: DevExpress.XtraBars.v24.2.dll

NuGet Package: DevExpress.Win.Navigation

#Declaration

[DXCategory("Events")]
public event EventHandler<RibbonSearchMenuEnterPressedEventArgs> SearchMenuEnterPressed

#Event Data

The SearchMenuEnterPressed event's data class is RibbonSearchMenuEnterPressedEventArgs. The following properties provide information specific to this event:

Property Description
SearchString Gets text entered in the search box. Inherited from RibbonSearchMenuBaseEventArgs.

The event data class exposes the following methods:

Method Description
ExecuteFirstSearchResult() Executes the action associated with the first item in the search menu.
HideSearchMenu() Hides the search menu.

#Remarks

The following code snippet saves the user query, executes the first found item, and closes the Search Menu on the Enter key press:

List<string> mruStrings = new List<string>();

void ribbonControl1_SearchMenuEnterPressed(object sender, RibbonSearchMenuEnterPressedEventArgs e) {
    if (!mruStrings.Contains(e.SearchString))
        mruStrings.Insert(0, e.SearchString);
    e.ExecuteFirstSearchResult();
    e.HideSearchMenu();
}
See Also