Dynamic create tab pages on a tab control

  • Thread starter Thread starter Jeff
  • Start date Start date
J

Jeff

I done some looking on Google and could not come up with a way to
dynamically create tab pages on a tab control.

Does anyone have a link to any examples.

Regards
Jeff
 
Jeff,

Why not just use the Add method on the TabPageCollection returned by the
TabPages property on the TabPage control?

// The tabpage.
TabPage tabPage = new TabPage();

// Add to the tab control.
tabControl.TabPages.Add(tabPage);
 
Thanks Nicholas

I have come from another programming language where each tab was a form
and thought this would be harder than you just indicated.

Ok now how can I stop the pages from being added to the form on
initialization.

At the moment when a form open it creates all the tabs which takes time.
Is there a property I can set to prevent the pages being created and
then use this method to add the ones I want.
 
Jeff,

If you don't want the pages to be added when the form is opened, then
you will have to remove the pages, and then add them programatically
elsewhere.

You can look at the designer-generated code and move that to another
section.
 
Back
Top