How to Customize the Office Search Box
- 2 minutes to read
The Office Search box enables users to find and activate specific UI elements in the search source menu. This tutorial demonstrates how to adjust the control’s appearance and behavior after the basic functionality setup.
For instance, you can make the search box like the Microsoft “Tell Me” text field.
You can mark the search box in your UI with a glyph via the Properties.Glyph property.
To display text that identifies the control, assign a text string to Properties.NullString and set the Properties.UseNullString property to True.
To restrict the search result list only to the most relevant items, you can:
Limit the drop-down menu size via the Properties.MaxResultCount.
Not allow the control to display nested items in search results with the Properties.RecursiveSearch.
Omit disabled items from the drop-down menu via the OnDropDownMenuItemAdding event (see the code example below).
procedure MyForm.dxOfficeSearchBox1PropertiesDropDownMenuItemAdding(Sender: TdxOfficeSearchBoxProperties; const ASearchText: string; ASourceItem: TObject; var AAllow: Boolean);
var
AItem: TdxBarItemLink;
begin
if(ASourceItem is TdxBarItemLink)
begin
AItem := TdxBarItemLink(ASourceItem);// Casts the ASourceItem parameter to the TdxBarItemLink type
if AItem.Item.Enabled then
AAllow := True
else
AAllow := False;
end;
end;
To finalize the control’s customization, define whether its drop-down menu can display a path to a UI item. This feature is useful if the same item belongs to the different toolbars and you want to obtain the shortest path to the item or choose the corresponding path from the list of valid paths and display it as a search result.
Now run the customized office search box.