RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
TCoolBands.Items Property

Lists the bands in the TCoolBands.

Pascal
property Items [Index: Integer]: TCoolBand;
C++
__property TCoolBand Items[int Index];

Use Items to access individual cool bands. The value of the Index parameter corresponds to the Index property of TCoolBand. It represents the position of the band in the TCoolBands collection.  

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 = (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(pCurrent->ClassType());
      CoolBar->Bands->Items[CoolBar->Bands->Count - 1]->Text = S;
    }
  }
}

void __fastcall TForm1::FormCreate(TObject *Sender)
{
  TCoolBar *CoolBar = new TCoolBar(this);
  TList *List;
  CoolBar->Parent = this;
  CoolBar->Align = alTop;
  List = new TList();
  try
  {
    TControl *Control;
    Control = new TButton(CoolBar);
    List->Add(Control);
    Control = new TCheckBox(CoolBar);
    List->Add(Control);
    Control = new TEdit(CoolBar);
    List->Add(Control);
    AddBands(CoolBar, List);
  }
  catch (...)
  {
    ShowMessage("Some objects could not be added to Coolband");
  }
  delete List;
}

 

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;

 

Items 

Index 

operator_[]

Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
What do you think about this topic? Send feedback!