vcl-155067-expressbars-how-to-add-a-standalone-editor-to-a-toolbar.md
In addition to built-in bar editors, the ExpressBars Suite also allows you to place standalone editors from the ExpressEditors library onto any toolbar or menu. This topic demonstrates how to add a standalone editor from this library to a toolbar at design and runtime.
To add an editor programmatically you need to:
add a TcxBarEditItem by passing the TcxBarEditItem as an argument into the TdxBarItemLinks.AddItem method;
use the item’s TcxBarEditItem.PropertiesClass or TcxBarEditItem.PropertiesClassName property to associate the desired ExpressEditors with the item.
The following code snippet adds a TcxCalcEdit, and it assumes that a bar named Custom 1 has already been added to the ExpressBars6MainForm form.
uses
..., cxCalc, cxBarEditItem;
procedure TExpressBars6MainForm.FormCreate(Sender: TObject);
var
ABarManager : TdxBarManager;
ABar : TdxBar;
ABarEditItem: TcxBarEditItem;
begin
ABarManager := GetBarManagerByForm(ExpressBars6MainForm);
with ABarManager do
begin
ABar := BarByCaption('Custom 1');
if ABar <> nil then
begin
BeginUpdate;
try
ABarEditItem := TcxBarEditItem(ABar.ItemLinks.AddItem(TcxBarEditItem).Item);
with ABarEditItem do
begin
PropertiesClass := TcxCalcEditProperties;
Caption := 'Calc Edit';
ShowCaption := True;
end;
finally
EndUpdate;
end;
end;
end;
end;
#pragma link "cxCalc"
#pragma link "cxBarEditItem"
// ...
void __fastcall TExpressBars6MainForm::FormCreate(TObject *Sender)
{
TdxBarManager * ABarManager;
TdxBar * ABar;
TcxBarEditItem * ABarEditItem;
ABarManager = GetBarManagerByForm(ExpressBars6MainForm);
ABar = ABarManager->BarByCaption("Custom 1");
if (ABar != NULL)
{
ABarManager->BeginUpdate();
try
{
ABarEditItem = (TcxBarEditItem*)(ABar->ItemLinks->AddItem(__classid(TcxBarEditItem))->Item);
ABarEditItem->PropertiesClass = __classid(TcxCalcEditProperties);
ABarEditItem->Caption = "Calc Edit";
ABarEditItem->ShowCaption = True;
}
__finally
{
ABarManager->EndUpdate();
}
}
}
The following image shows the result when the above code executes.
To add a standalone editor at design time, right-click the desired bar and choose Add cxEditItem and then select the appropriate editor type within the submenu (see the image below).
See Also
TcxCustomBarEditItem.PropertiesClass