Mega Code Archive

 
Categories / Delphi / VCL
 

Add a page to a tabbed notebook [ttabbednotebook]

This example shows you how to create a page and add it to a TTabbedNotebook at runtime and how to add controls to it. The code originates from Graham Mainwaring. procedure AddPage; var btnNew : TButton; NewPage: TTabPage; wNumber: Word; begin { AddPage } // 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 wNumber := TabbedNotebook1.Pages.Add('New Page'); TabbedNotebook1.PagesObjects[wNumber] := NewPage; // The page needs controls on it; here's how to add one btnNew := TButton.Create(Self); TWinControl(TabbedNotebook1.Pages.Objects[wNumber]).InsertControl(btnNew); with btnNew do begin Top := 10; Height := 30; Width := 100; Caption := 'OK' end; { with btnNew } end; { AddPage }