vcl-dxofficesearchbox-df40c8b9.md
The procedural type for search result population events in TdxOfficeSearchBox editors.
TdxOfficeSearchBoxDropDownMenuItemAddingEvent = procedure(Sender: TdxOfficeSearchBoxProperties; const ASearchText: string; ASourceItem: TObject; var AAllow: Boolean) of object;
| Name | Type | Description |
|---|---|---|
| Sender | TdxOfficeSearchBoxProperties |
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. |
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.
A search result population event occurs every time a TdxOfficeSearchBox editor is about to add a search result to a drop-down menu.
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;
#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;
}
}
The TdxOfficeSearchBoxProperties.OnDropDownMenuItemAdding event references the TdxOfficeSearchBoxDropDownMenuItemAddingEvent procedural type.
See Also
TdxOfficeSearchBoxDropDownMenuItemAddedEvent Procedural Type