I have three forms named, MainForm, Form1 and Form2. In MainForm there is one TabControl. I want to open the forms: Form1 and Form2 as new tab in MainForm. I am using Visual Studio and language VB.Net. Is there any way to open the forms as new tab?
Share
You could change Form1 and Form2 both to be
UserControls, you can then load those usercontrols a the contents of the tabs.To change the Form to a UserControl change the following line:
to
Best practice is to also rename the Form1 by renaming the file in the Solution Explorer. VS should show you a popup window:
Microsoft Visual Studio
You are renaming a file. Would you also like to perform a rename in this project of all references to the code element ‘Form1’?
Yes No
Click
YesThen Build your solution, and open your main form with the TabControl in it. Also open the ToolBox window, you should see your new UserControl listed on the top. You can now drag ‘n drop your usercontrol onto the TabPage that you want.
Question: do you need to show Form1 and Form2 as actual Forms as well?
If yes, you can create Form1 with a single child: UserControl1 and Form2 with a single child: UserControl2
Hth