Skip to main content

TdxBar, TdxBars.Add, TdxBarItemLink, TdxBarItemLink.Item, TdxBarColorCombo, TdxBarButton Example

This example requires a form with a TdxBarManager and a TdxBarButton object. The following code adds a new toolbar to the form and creates a button with a color combo. The procedures to add the new item controls to the toolbars are similar to this code:

var
  ABarManager : TdxBarManager;
  ABar : TdxBar;
  NewButton : TdxBarButton;
  NewColorCombo : TdxBarColorCombo;
  NewItemLink : TdxBarItemLink;
begin
  // Gets the bar manager
  ABarManager := GetBarManagerByForm(Form1);
  // New toolbar
  ABar := ABarManager.Bars.Add;
  ABar.Caption := 'New toolbar';
  ABar.DockingStyle := dsTop;
  ABar.FloatLeft := Form1.Left+(Form1.Width div 2);
  ABar.FloatTop :=  Form1.Height div 2;
  // New Button
  NewButton := TdxBarButton.Create(Form1);
  // Sets the OnClick event handler.
  // The OnClick1 procedure has been already defined.
  NewButton.OnClick := OnClick1;
  // Creates and adds the new item control to the toolbar
  NewItemLink := ABar.ItemLinks.Add;
  NewItemLink.Item := NewButton;
  NewButton.Caption := 'NewButton';
  // New Color Combo
  NewColorCombo := TdxBarColorCombo.Create(Form1);
  // Creates and adds the new item control to the toolbar
  NewItemLink := ABar.ItemLinks.Add;
  NewItemLink.Item := NewColorCombo;
  NewColorCombo.Color := clNavy;
  // Makes the toolbar visible
  ABar.Visible := True;
end;