Unit 'ExtCtrls' Package
[Overview][Types][Classes][Procedures and functions][Index] [#lcl]


Contains the page names and TPage instances defined for the notebook control.


Source position: extctrls.pp line 152

published property TNotebook.Pages : TStrings
  read FPages
  write SetPages
  stored False;


Pages is a TStrings property which contains the page names and associated TPage instances for the pages defined for the notebook control.

When the component is created, a TUNPages instance is created and assigned to the property member. It provides overridden methods which maintain the TPage instance associated with a given page name. You can use the Pages property editor in the Object Inspector to maintain the page names and their TPage instances.

To add a page to Pages at run-time:

procedure TForm1.AddButtonClick(Sender: TObject);
  NewPageIndex: integer;
  NewPage: TPage;
  PageLabel: TLabel;
  NewPageIndex := Notebook1.Pages.Add(Format('[Page %d]', [Notebook1.Pages.Count]));
  NewPage := Notebook1.Page[NewPageIndex];
  NewPage.Color := RgbToColor(Random(128)+127, Random(128)+127, Random(128)+127);
  PageLabel := TLabel.Create(Self);
  with PageLabel do
    Left := 20;
    Top := 10 + NewPageIndex * 20;
    Width := 500;
    Height := 20;
    Caption := Format('This is page [%d]',[NewPageIndex]);
    Parent := NewPage;
  Label1.Caption := IntToStr(Notebook1.PageCount)+ ' pages total';

Use the indexed Page property to access the TPage instance for a given page by its ordinal position. Use PageIndex to set the active page in the notebook control by its ordinal position in Pages. For example:

procedure TForm1.PrevButtonClick(Sender: TObject);
  if Notebook1.PageIndex > 0 then
    Notebook1.PageIndex := Notebook1.PageIndex - 1;

procedure TForm1.NextButtonClick(Sender: TObject);
  if Notebook1.PageIndex < Notebook1.PageCount-1 then
    Notebook1.PageIndex := Notebook1.PageIndex + 1;

Assigning a new TStrings value to Pages causes the new page names to be compared to the existing internal page objects (TPage) in the notebook. New or altered pages are added or replaced in the notebook as needed. An existing page object not present in the new page names is deleted. The Application singleton is notified that the page object is being released and allowed to process the message.

A new value assigned to Pages is not stored at design-time. Use the Object Inspector to maintain the values in the property.

See also



TPage: One of the pages in a tabbed Notebook.



Represents page names and page class instances for a notebook.


CT Web help

CodeTyphon Studio