By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,168 Members | 2,598 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,168 IT Pros & Developers. It's quick & easy.

Form as TabPage???

P: n/a
Hi everyone:

I have a form that has a tab control on it with 4 pages. There is a
lot of code behind each page as well as many controls on each page so I
decided to make each indidvidual page a seperate form, for organization
purposes. I am getting an error when I try to add the form to the tab
control. The error message tells me that the form cannot be converted
to type tabpage. Here is the code I am using:

Dim frm as new Form1
tabMain.TabPages.Add(frm)

Does anyone have any ideas?

I should also mention that I am still pretty new to VB.NET so I wanted
to ask if I am doing this the proper way. Is there a different
methodology that I should be following?

Thank you in advance for your insight!

Nov 21 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
"GatorBait" <MP****@gmail.com> schrieb:
I have a form that has a tab control on it with 4 pages. There is a
lot of code behind each page as well as many controls on each page so I
decided to make each indidvidual page a seperate form, for organization
purposes. I am getting an error when I try to add the form to the tab
control. The error message tells me that the form cannot be converted
to type tabpage.


I suggest to use usercontrols instead of forms which should be embedded into
the tabcontrol. Choose "Project" -> "Add user control..." to add a
usercontrol to your project.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #2

P: n/a
GatorBait wrote:
Dim frm as new Form1
tabMain.TabPages.Add(frm)


Change your code to this:

Dim frm As new Form1
frm.TopLevel = False
frm.Parent = tabMain.TabPages(0)

frm.Show()
The form should now be visible inside the tab page. You might want to
set the form's FormBorderStyle property to none.

Nov 21 '05 #3

P: n/a
Herfried K. Wagner [MVP] wrote:
I suggest to use usercontrols instead of forms which should be embedded into
the tabcontrol. Choose "Project" -> "Add user control..." to add a
usercontrol to your project.


Herfried, do you know if there is any technical reason not to use a
form? Both the Form class and UserControl class have the same
inheritance chain. And, of course, Form has other properties that
UserControl might not have.

I am just curious.

Nov 21 '05 #4

P: n/a
Chris,

"Chris Dunaway" <du******@gmail.com> schrieb:
I suggest to use usercontrols instead of forms which should be embedded
into
the tabcontrol. Choose "Project" -> "Add user control..." to add a
usercontrol to your project.


Herfried, do you know if there is any technical reason not to use a
form? Both the Form class and UserControl class have the same
inheritance chain. And, of course, Form has other properties that
UserControl might not have.


Forms are not designed for being embedded into other controls or forms,
except in MDI scenarios.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.