Back to Devexpress

How to Add Buttons to a Toolbar

vcl-155074-expressbars-how-to-add-buttons-to-a-toolbar.md

latest1.6 KB
Original Source

How to Add Buttons to a Toolbar

  • Dec 28, 2020

This topic demonstrates how to add buttons to toolbars at design and runtime.

To add a button at design time, right-click on a toolbar and select Add Button from the popup menu.

To add a large button, select Add LargeButton.

When coding, you should create a link to the button within a toolbar. The following code snippet adds a button to the first toolbar.

delphi
// ...
procedure TForm1.AddButtonClick(Sender: TObject);
begin
  with dxBarManager do
  begin
    BeginUpdate;
    try
      with Bars[0].ItemLinks.AddButton do
      begin
        Item.Caption := '&File';
        UserPaintStyle := psCaption;
      end;
    finally
      EndUpdate;
    end;
  end;
end;
cpp
// ...
void __fastcall TForm1::AddButtonClick(TObject *Sender)
{
  TdxBarItemLink * NewItemLink;
  dxBarManager->BeginUpdate();
  try {
    NewItemLink = dxBarManager->Bars->Items[0]->ItemLinks->AddButton();
    NewItemLink->Item->Caption = "&File";
    NewItemLink->UserPaintStyle = psCaption;
  }
  __finally {
    dxBarManager->EndUpdate();
  }
}

See Also

TdxBarItem.Caption

TdxBarItemLink.UserPaintStyle

TdxBarItemLinks.Add

TdxBarItemLinks.AddButton