RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
TStatusPanels.Add Method

Creates a new TStatusPanel instance and adds it to the Items array.

Pascal
function Add: TStatusPanel;
C++
__fastcall TStatusPanel Add();

Add returns the new status panel. At design time, use the Panels editor to add panels to the status bar.  

C++ Examples: 

 

/*
The following example adds a panel to the status bar control
when the user clicks the button and adds a caption to the 
panel. The code uses BeginUpdate and EndUpdate to prevent 
repaints until the operation is complete.  A try...finally 
block ensures EndUpdate is called even when an exception 
occurs.
*/
void __fastcall TForm1::Button1Click(TObject *Sender)
{
  int PanelIndex;

  StatusBar1->Panels->BeginUpdate();
  PanelIndex = StatusBar1->Panels->Count - 1;
  try
  {
    StatusBar1->Panels->Add();
    PanelIndex++;
    StatusBar1->Panels->Items[PanelIndex]->Text = "Panel" + IntToStr(PanelIndex);
  }
  __finally
  {
    StatusBar1->Panels->EndUpdate();
  }
}

 

Delphi Examples: 

{
The following example adds a panel to the status bar control
when the user clicks the button and adds a caption to the 
panel. The code uses BeginUpdate and EndUpdate to prevent 
repaints until the operation is complete.  A try...finally 
block ensures EndUpdate is called even when an exception 
occurs.
}
procedure TForm1.Button1Click(Sender: TObject);
var
  PanelIndex : Integer;
begin
  with StatusBar1 do
  begin
    Panels.BeginUpdate;
    PanelIndex := StatusBar1.Panels.Count - 1;
    try
      Panels.Add;
      Inc(PanelIndex);
      Panels.Items[PanelIndex].Text := 
        'Panel' + IntToStr(PanelIndex);
    finally
      Panels.EndUpdate;
    end;
  end;
end;

 

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