Mega Code Archive
How can i add pages to a ttabbednotebook at run-time
The following source code, which assumes that you have a tabbed notebook
called TabbedNotebook1, will add a new page that contains an "OK" button:
procedure whatever_whenever;
var
NewPage: TTabPage;
NewPageNumber: word;
NewButton: TButton;
begin
{Create the new TTabPage object}
NewPage := TTabPage.Create(Application);
{The page must be a child of the notebook}
TabbedNotebook1.InsertControl(NewPage);
{Add text to the notebook's Pages property; this will cause the new
page to be added as the last tab on the notebook}
NewPageNumber := TabbedNotebook1.Pages.Add(`New Page');
TabbedNotebook1.PagesObjects[NewPageNumber] := NewPage;
{The page needs controls on it; here's how to add one}
NewButton := TButton.Create(Self);
(TabbedNotebook1.Pages.Objects[NewPageNumber] as TWinControl)
.InsertControl(NewButton);
NewButton.Top := 10;
NewButton.Height := 30;
NewButton.Width := 100;
NewButton.Caption := `OK';
end;