TTMSFNCToolBar.AddCustomControl Method
Adds an existing control instance to the toolbar at the given position.
API unit family: TMSFNCToolBar
Declaring type: TTMSFNCToolBar
Inherited from: TTMSFNCCustomToolBar
Syntax
procedure AddCustomControl(AControl: TControl; AIndex: Integer = -1); virtual;
virtual void __fastcall AddCustomControl(Fmx::Controls::TControl* AControl, int AIndex = 0xffffffff);
Parameters
| Name | Description |
|---|---|
AControl |
The control to insert. |
AIndex |
Zero-based insertion index, or -1 to append. |
Usage examples
Host an existing control instance on the toolbar
Creates and configures a control, then inserts the existing instance with AddCustomControl.
procedure TForm1.HostExistingControl;
var
Search: TEdit;
begin
// Create and configure the control yourself...
Search := TEdit.Create(Self);
Search.Width := 180;
Search.TextPrompt := 'Search';
Search.OnChangeTracking := SearchChanged;
// ...then hand the existing instance to the toolbar. Use AddCustomControl for
// a control you already own; use AddCustomControlClass when the toolbar should
// create and own the control from a class.
TMSFNCToolBar1.AddCustomControl(Search);
TMSFNCToolBar1.Build;
end;
procedure TForm1.SearchChanged(Sender: TObject);
begin
{ Filter the document as the user types in the hosted search box. }
end;
void __fastcall TForm1::HostExistingControl()
{
// Create and configure the control yourself...
TEdit *Search = new TEdit(this);
Search->Width = 180;
Search->TextPrompt = "Search";
Search->OnChangeTracking = SearchChanged;
// ...then hand the existing instance to the toolbar. Use AddCustomControl for
// a control you already own; use AddCustomControlClass when the toolbar should
// create and own the control from a class.
TMSFNCToolBar1->AddCustomControl(Search);
TMSFNCToolBar1->Build();
}
void __fastcall TForm1::SearchChanged(TObject *Sender)
{
// Filter the document as the user types in the hosted search box.
}