Form as a TabPage?

G

GatorBait

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!
 
P

Phil G.

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top