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
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);
If all you'll be doing is copying controls from a TabControl on one form to a TabControl on another form:
- Instantiate the form you want to copy from
- Find the TabControl on that form
- Iterate through Controls on the TabPages inside that TabControl
- Add each Control you find in that collection to the tab(s) in the control you want to copy to
- Close and Dispose of the form you created in step 1
Yes, it is possible. You have to add the controls onto the TabPage, then add the TabPage to the TabControl.TabPages