RAD Studio VCL Reference
|
Lists the bands (TCoolBands) of the coolbar.
property Bands: TCoolBands;
__property TCoolBands Bands;
The Bands property holds a TCoolBands collection. At design time, you can add, remove, or modify bands with the Bands editor. To open the Bands editor, select the Bands property in the Object Inspector, then double-click in the Value column to the right or click the ellipsis (...) button.
You can also create bands simply by adding new wrapper controls from the palette. When any TWinControl descendant is placed on the form as a child of the TCoolBar, a new band is created for it.
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!
|