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 a TabPage?

P: n/a
Hi everyone,

I have a tabcontrol on a form that contains 4 tabs. I want to make
each tab a seperate form because there is a great deal of code behind
each page, and organizationally it was easier to have each one
seperate. My idea was to just add and remove each form as necessary
based on what page the user clicked on, but I am getting an error when
I try to add the form as a tabpage:

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

It is telling me that type form cannot be converted to type TabPage.
Any ideas???

Also, I'm still relatively new to vb.net, so I should also pose the
question: Am I doing this the proper way, or should I be doing this in
a different manner?

Thank you in advance for your insight!

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


P: n/a
"GatorBait" <MP****@gmail.com> schrieb:
[...]


This is a double post. Please continue discussion in the other "instance"
of the thread.

--
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
Hi,

Not sure about this! When you say that you have a lot of 'code behind', does
this mean that you are programming asp.net? If so, then I am not very
familiar...sorry!

If you are coding for windows forms, then my next question is.....Do you
really need a 'Form' or do you just need a container for your other
controls? With the TabControl I usually use panels to add my controls to.

You code is slightly incorrect and the error message is understandable. What
you are actually doing is attempting to ad a control of type form when it is
expecting a control of type tabpage. You need to use
Me.tabMain.TabPages(index).Controls.Add(control). This will not work if you
try to add a form and I'm not sure that you can accomplish this........but
I'm sure there will be someone with a definite answer!

I hope this gives you something to work with.

Good luck. Phil

"GatorBait" <MP****@gmail.com> wrote in message
news:11**********************@g49g2000cwa.googlegr oups.com...
Hi everyone,

I have a tabcontrol on a form that contains 4 tabs. I want to make
each tab a seperate form because there is a great deal of code behind
each page, and organizationally it was easier to have each one
seperate. My idea was to just add and remove each form as necessary
based on what page the user clicked on, but I am getting an error when
I try to add the form as a tabpage:

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

It is telling me that type form cannot be converted to type TabPage.
Any ideas???

Also, I'm still relatively new to vb.net, so I should also pose the
question: Am I doing this the proper way, or should I be doing this in
a different manner?

Thank you in advance for your insight!

Nov 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.