RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
TPageControl.SelectNextPage Method

Changes the ActivePage to the first visible page that is before or after the currently active page.

Pascal
procedure SelectNextPage(GoForward: Boolean; CheckTabVisible: Boolean = True);
C++
__fastcall SelectNextPage(Boolean GoForward, Boolean CheckTabVisible = True);

Use SelectNextPage to select the page next to the currently active page.  

If the GoForward parameter is true, SelectNextPage selects the first page after ActivePage; if GoForward is false, SelectNextPage selects the first page previous to ActivePage.  

If CheckTabVisible is true, SelectNextPage only considers pages with their TabVisible property set to true.

Note: To select a page at design-time, right-click the TPageControl and choose Previous Page or Next Page.
 

C++ Examples: 

 

/*
This example requires a new TPageControl, as-is, with no new pages
created at design time, and a TUpDown control, also from the Win95
page of the component palette.  The form OnCreate event handler
adds several new TabSheet controls to the Page Control.  The 
UpDown1Click event handler fires when the user clicks the up or
down button on the TUpDown control.  The SelectNextPage method of
the Page Control goes forward the comparison (Button = btNext)
evaluates as true.  If Button is not btNext, the previous Tab Page
is selected.
*/
void __fastcall TForm1::FormCreate(TObject *Sender)
{
const
  TColor colorPalette[12] = {
    clRed, clGreen, clYellow, clBlue, clWhite, clFuchsia,
    clTeal, clNavy, clMaroon, clLime, clOlive, clPurple};
  for (int i = 0; i < 10; i++)
  {
    TTabSheet *page = new TTabSheet(PageControl1);
    page->PageControl = PageControl1;
    page->Caption = AnsiString("Page") + IntToStr(i);
    page->Brush->Color = colorPalette[i];
  }
}

void __fastcall TForm1::UpDown1Click(TObject *Sender, TUDBtnType Button)
{
  PageControl1->SelectNextPage(Button == btNext);
}

 

Delphi Examples: 

{
This example requires a new TPageControl, as-is, with no new pages
created at design time, and a TUpDown control, also from the Win95
page of the component palette.  The form OnCreate event handler
adds several new TabSheet controls to the Page Control.  The 
UpDown1Click event handler fires when the user clicks the up or
down button on the TUpDown control.  The SelectNextPage method of
the Page Control goes forward the comparison (Button = btNext)
evaluates as true.  If Button is not btNext, the previous Tab Page
is selected.
}
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
  for i := 0 to 9 do
    with TTabSheet.Create(Self) do
    begin
      PageControl := PageControl1;
      Caption := 'TabSheet #' + IntToStr(i);
      Brush.Color := colorPalette[i];
    end;
end;

procedure TForm1.UpDown1Click(Sender: TObject; Button: TUDBtnType);
begin
  PageControl1.SelectNextPage(Button = btNext);
end;

 

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