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 |
---|---|
Search |
Gets text entered in the search box.
Inherited from Ribbon |
The event data class exposes the following methods:
Method | Description |
---|---|
Execute |
Executes the action associated with the first item in the search menu. |
Hide |
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();
}