RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
TCoolBand.Text Property

Specifies the text string that appears on the band and identifies it in the Bands editor.

Pascal
property Text: string;
C++
__property AnsiString Text;

Assign a value to Text to create text that appears on the band on the left of the band.  

C++ Examples: 

 

/*
To run this example, add the example code to a new project.
The example code dynamically creates a TCoolbar and three
TCoolBand objects populated with a windowed control in each
TCoolBand.
*/
void AddBands(TCoolBar *CoolBar, TList *Objects)
{
  TControl *pCurrent;
  for (int i = 0; i < Objects->Count; i++)
  {
    pCurrent = reinterpret_cast<TControl *>(Objects->Items[i]);
    // only add windowed controls to the coolbar
    if (dynamic_cast<TWinControl *>(pCurrent) != NULL)
    {
      // Placing the control onto the CoolBar
      // causes the TCoolBar object to create a TCoolBand 
      // and place the control within the band.
      pCurrent->Parent = CoolBar;   // This statement increments CoolBar->Bands->Count.
      // Get the reference of the TCoolBand just created and assign text.
      String S = pCurrent->ClassName();
      CoolBar->Bands->Items[CoolBar->Bands->Count - 1]->Text = S;
    }
  }
}

#include <memory>       //for STL auto_ptr class

void __fastcall TForm1::FormCreate(TObject *Sender)
{
  TCoolBar *CoolBar = new TCoolBar(this); // The Ownder (Form1) will clean this up.
  CoolBar->Parent = this;
  CoolBar->Align = alTop;
  std::auto_ptr<TList> List(new TList);
  try
  {
    TControl *Control;
    Control = new TButton(CoolBar); // The Ownder (CoolBar) will clean this up.
    List->Add(Control);
    Control = new TCheckBox(CoolBar); // The Ownder (CoolBar) will clean this up.
    List->Add(Control);
    Control = new TEdit(CoolBar); // The Ownder (CoolBar) will clean this up.
    List->Add(Control);
    AddBands(CoolBar, List.get());
  }
  catch (...)
  {
    ShowMessage("Some objects could not be added to Coolband");
  }
}

 

Delphi Examples: 

{
To run this example, add the example code to a new project.
The example code dynamically creates a TCoolBar and three
TCoolBand objects populated with a windowed control in each
TCoolBand.
}
procedure AddBand(CoolBar: TCoolBar; Const ControlClasses: array of TControlClass);
var
  CurrentControl: TControl;
  I: Integer;
begin
  for I := 0 to High(ControlClasses) do
    begin
      CurrentControl := ControlClasses[i].Create(CoolBar);
      if (CurrentControl is TWinControl) then
      begin
        { Placing the control onto the CoolBar causes the TCoolBar object to create a TCoolBand and place the control within the band. }
        CurrentControl.Parent := Coolbar;
        { Get the reference of the last TCoolBand created and assign text. }
        with CoolBar.Bands do
          Items[count - 1].Text := CurrentControl.ClassName;
      end;
    end;
end;

procedure TForm1.FormCreate(Sender: TObject);
var
  CoolBar: TCoolBar;
begin
  CoolBar := TCoolBar.Create(Self);
  CoolBar.Parent := Self;
  CoolBar.Align := alClient;
  AddBand(CoolBar, [TCheckBox, TEdit, TButton]);
end;

 

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!