Skip to main content
All docs
V24.1

RibbonControl.SearchMenuEnterPressed Event

Occurs when a user presses Enter in the search box.

Namespace: DevExpress.XtraBars.Ribbon

Assembly: DevExpress.XtraBars.v24.1.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