DelphiFAQ Home Search:

Add a page to a tabbed notebook (TTabbedNotebook)

 

comments1 comments. Current rating: 5 stars (1 votes). Leave comments and/ or rate it.

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 } 
You don't like the formatting? Check out SourceCoder then!

Comments:

2008-09-30, 04:10:56
anonymous from Iran  
rating

 

 

NEW: Optional: Register   Login
Email address (not necessary):

Rate as
Hide my email when showing my comment.
Please notify me once a day about new comments on this topic.
Please provide a valid email address if you select this option, or post under a registered account.
 

Show city and country
Show country only
Hide my location
You can mark text as 'quoted' by putting [quote] .. [/quote] around it.
Please type in the code:
photo Add a picture:

Please do not post inappropriate pictures. Inappropriate pictures include pictures of minors and nudity. The owner of this web site reserves the right to delete such material.