Dynamic create tab pages on a tab control

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
 
N

Nicholas Paldino [.NET/C# MVP]

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);
 
J

Jeff

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.
 
N

Nicholas Paldino [.NET/C# MVP]

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top