RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
TTabSheet.PageIndex Property

Indicates the index of the tab sheet in the list of tab sheets maintained by the page control.

Pascal
property PageIndex: Integer;
C++
__property int PageIndex;

Use PageIndex to determine where the tab sheet sits in its page control. Each tab sheet in a page control is automatically assigned a PageIndex when it is inserted in the page control. The first tab sheet receives a value of 0, the second has a value of 1, and so on. PageIndex values are reassigned if tab sheets are deleted or moved. 

To access a particular tab sheet given its index value, use the indexed Pages property of the TPageControl object.  

C++ Examples: 

 

/*
This example creates ten Tab Sheets and sets the captions to
display PageIndex and TabIndex for each tab.  Odd numbered
tabs have their TabVisible property set off to demonstrate
the effect on PageIndex vs TabIndex.  On the series of
visible tabs, PageIndex will read 0, 2, 4, 6, 8, and
TabIndex will read 0, 1, 2, 3, 4.  PageIndex counts only
visible tabs.
*/
void __fastcall TForm1::FormCreate(TObject *Sender)
{
  const TColor colorPalette[12] = {
    clRed, clGreen, clYellow, clBlue, clWhite, clFuchsia,
    clTeal, clNavy, clMaroon, clLime, clOlive, clPurple};
  PageControl1->MultiLine = true;
  for (int i = 0; i < 10; i++)
  {
    TTabSheet *page = new TTabSheet(this); // These tabsheets will be cleaned up by their owner (this).
    page->PageControl = PageControl1;
    page->TabVisible = (i % 2 == 0);
    page->Caption =
      AnsiString("PageIndex: ") + IntToStr(page->PageIndex) +
      AnsiString("  TabIndex: ") + IntToStr(page->TabIndex);
    page->Brush->Color = colorPalette[i];
  }
}

 

Delphi Examples: 

{
This example creates ten Tab Sheets and sets the captions to
display PageIndex and TabIndex for each tab.  Odd numbered
tabs have their TabVisible property set off to demonstrate
the effect on PageIndex vs TabIndex.  On the series of
visible tabs, PageIndex will read 0, 2, 4, 6, 8, and
TabIndex will read 0, 1, 2, 3, 4.  PageIndex counts only
visible tabs.
} 
procedure TForm1.FormCreate(Sender: TObject);
var
  i: Integer;
const
  colorpalette: Array[0..11] of TColor = (
    clRed, clGreen, clYellow, clBlue, clWhite, clFuchsia,
    clTeal, clNavy, clMaroon, clLime, clOlive, clPurple);
begin
  with PageControl1 do
    for i := 0 to 9 do
      with TTabSheet.Create(Self) do
      begin
        PageControl := PageControl1;
        TabVisible := (PageIndex mod 2 = 0);
        Brush.Color := colorpalette[i];
        Caption := 'PageIndex: ' +
        IntToStr(PageIndex) + '  TabIndex: ' +
          IntToStr(TabIndex);
      end;
end;

 

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