[Overview][Types][Classes][Procedures and functions][Index] |
Contains the page names and TPage instances defined for the notebook control.
Source position: extctrls.pp line 153
published property TNotebook.Pages : TStrings |
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); var NewPageIndex: integer; NewPage: TPage; PageLabel: TLabel; begin 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 begin Left := 20; Top := 10 + NewPageIndex * 20; Width := 500; Height := 20; Caption := Format('This is page [%d]',[NewPageIndex]); Parent := NewPage; end; Label1.Caption := IntToStr(Notebook1.PageCount)+ ' pages total'; end;
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); begin if Notebook1.PageIndex > 0 then Notebook1.PageIndex := Notebook1.PageIndex - 1; end; procedure TForm1.NextButtonClick(Sender: TObject); begin if Notebook1.PageIndex < Notebook1.PageCount-1 then Notebook1.PageIndex := Notebook1.PageIndex + 1; end;
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.
|
TPage: One of the pages in a tabbed Notebook. |
|
|
Represents page names and page class instances for a notebook. |
|
Version 4.0 | Generated 2025-05-03 | Home |