Skip to main content

TdxOfficeSearchBoxProperties.OnDropDownMenuItemAdding Event

Allows you to exclude certain search results from a drop-down menu.

Declaration

property OnDropDownMenuItemAdding: TdxOfficeSearchBoxDropDownMenuItemAddingEvent read; write;

Remarks

An Office Search Box editor displays found UI commands in a drop-down menu. Users can click menu items to execute corresponding UI commands.

!VCL Bars: UI Command Search Results

You can handle an OnDropDownMenuItemAdding event to exclude certain search results from the editor’s drop-down menu.

Event Occurrence

The OnDropDownMenuItemAdding event occurs every time the TdxOfficeSearchBox editor is about to add a search result to a drop-down menu.

Event Parameters

The following parameters are available within an OnDropDownMenuItemAdding event handler:

Sender
Provides access to settings (a TdxOfficeSearchBoxProperties class instance) of the TdxOfficeSearchBox editor that raised the search result population event.
ASearchText
Returns the current user search query (the editor’s EditValue property value).
ASourceItem
Provides access to the bar item link associated with the UI command that is about to be added to a drop-down menu.
AAllow
Specifies if the editor adds the current search result to a drop-down menu. Assign False to this parameter within an OnCustomDrawCell event handler to prevent the search result from being added to the menu.

Refer to the TdxOfficeSearchBoxDropDownMenuItemAddingEvent procedural type description for detailed information on all options accessible within an OnCustomDrawCell event handler.

Code Example: Exclude Disabled Commands from Search Results

The following code example excludes disabled UI commands from search results:

uses
  dxOfficeSearchBox;  // Declares the TdxOfficeSearchBox class
// ...

procedure MyForm.dxOfficeSearchBox1PropertiesDropDownMenuItemAdding(Sender: TdxOfficeSearchBoxProperties;
  const ASearchText: string; ASourceItem: TObject; var AAllow: Boolean);
var
  AItem: TdxBarItemLink;
begin
  if ASourceItem is TdxBarItemLink then 
  begin
    AItem := ASourceItem as TdxBarItemLink;
    if not AItem.Item.Enabled then
      AAllow := False;  // Hides the currently processed UI command if it is disabled
  end;
end;
See Also