Reputation: 239
I have thought of this idea where you could have a tab control on a form, but instead of defining each tabs controls before runtime, inherit or use another form's controls.
Basically a tab control is in place on the main form that has no tabs on it before runtime. When runtime comes along I want to create tabs, but the controls that would be on each tab would be from seperate already created forms.
Each form would be a seperate tab that had been created prior to runtime.
Is this possible? Is so, how?
Thanks in advance
EDIT I'm using 3.5
Upvotes: 2
Views: 5351
Reputation: 50038
Yes, it is possible. You have to add the controls onto the TabPage, then add the TabPage to the TabControl.TabPages
Upvotes: 1
Reputation: 17081
If all you'll be doing is copying controls from a TabControl on one form to a TabControl on another form:
Upvotes: 1
Reputation: 16065
first create a User Control and design it as you would a regular form, then add it to your TabControl.TabPages
TabPage page = new TabPage("Title");
page.Controls.Add(new CustomUserControl()); //your user control
this.tabControl1.TabPages.Add(page);
Upvotes: 4