Back to Devexpress

TdxOfficeSearchBoxDropDownMenuItemAddingEvent Type

vcl-dxofficesearchbox-df40c8b9.md

latest3.9 KB
Original Source

TdxOfficeSearchBoxDropDownMenuItemAddingEvent Type

The procedural type for search result population events in TdxOfficeSearchBox editors.

Declaration

delphi
TdxOfficeSearchBoxDropDownMenuItemAddingEvent = procedure(Sender: TdxOfficeSearchBoxProperties; const ASearchText: string; ASourceItem: TObject; var AAllow: Boolean) of object;

Parameters

NameTypeDescription
SenderTdxOfficeSearchBoxProperties

Provides access to settings of the TdxOfficeSearchBox editor that raised the search result population event.

| | ASearchText | string |

Returns the current user search query (the editor’s EditValue property value).

| | ASourceItem | TObject |

Provides access to the bar item link associated with the UI command that is about to appear in a drop-down menu.

Tip

Cast the returned object to the TdxBarItemLink class to access all public API members of the target bar item link.

| | AAllow | Boolean | True Default. The Office Search Box editor adds the currently processed search result to a drop-down menu.FalseThe Office Search Box editor ignores the currently processed search result. |

Remarks

A search result population event in an Office Search Box editor allows you to exclude certain UI elements (disabled commands, for example) from a search result list displayed in a drop-down menu.

Event Occurrence

A search result population event occurs every time a TdxOfficeSearchBox editor is about to add a search result to a drop-down menu.

Code Example: Exclude Disabled Commands from Search Results

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

delphi
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;
cpp
#include "dxOfficeSearchBox.hpp" // Declares the TdxOfficeSearchBox class
// ...

void __fastcall TMyForm::dxOfficeSearchBox1PropertiesDropDownMenuItemAdding(
  TdxOfficeSearchBoxProperties *Sender, const UnicodeString ASearchText, TObject *ASourceItem, bool &AAllow)
{
  TdxBarItemLink *AItem;
  if(ASourceItem->InheritsFrom(TdxBarItemLink))
  {
    AItem = dynamic_cast<TdxBarItemLink*>(ASourceItem);
    if(!AItem->Item->Enabled)
      AAllow = False;
  }
}

Direct TdxOfficeSearchBoxDropDownMenuItemAddingEvent Type Reference

The TdxOfficeSearchBoxProperties.OnDropDownMenuItemAdding event references the TdxOfficeSearchBoxDropDownMenuItemAddingEvent procedural type.

See Also

TdxOfficeSearchBoxDropDownMenuItemAddedEvent Procedural Type

TdxOfficeSearchBoxDropDownMenuPopulateEvent Procedural Type

dxOfficeSearchBox Unit