473,378 Members | 1,388 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Form as TabPage???

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
4 15158
"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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Sleepy | last post by:
Visual Studio 2003 Windows Forms application: Is there a way that I can add a form as a TabPage? My goal is to develop a series of forms and load the dialogs dynamically in a tab control based...
2
by: GatorBait | last post by:
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...
4
by: Philip Wagenaar | last post by:
I have made a form with a tab that containts groupboxes and those contain checkboxes. When I run the application sometimes the outlining for some groupboxes are not shown, if I switch tabs and...
2
by: TN | last post by:
I can add a button to a TabPage, how come I can't add a Form? The Form never gets realized on the page, but a button can :-( f = new System.Windows.Forms.Form(); b = new Button(); b.Text =...
1
by: MLH | last post by:
I thought it was DoCmd.GoToPage - but that doesn't work for Tab Controls, it seems - only for forms with page breaks in them. Anybody know Syntax form moving from page-to-page (actually,...
8
by: Ryan | last post by:
Ok.. I have a form with lots of stuff on it; a tool strip panel, menu strip, data binding elements (dataset, binding source, table adapter), tab control with 7 tab pages, each page contains a...
5
by: Amit | last post by:
Can anyone write the code to hide tabpage of tab control in windows form 2.0 Thanks, Amit
12
by: Rob | last post by:
Let's say you open Form1 that contains TabControl1 There are several tabs on TabControl1 Now you open a new Form2 that contains a User Control How can you determine the Selected tab in Form1...
6
by: =?Utf-8?B?U2hhcm9u?= | last post by:
Hello gurus, I want to have a Form with a TabControl, this TabControl will contain TabPage that has controls in it, this TabPage is prepared at design time. I want in runtime to duplicate the...
1
by: RobcPettit | last post by:
Hi, I have two forms. From form1(frmMain) I want to add tabpages to Form2. In form1 I have: frmMain tbe = new frmMain(); Thread thread = new Thread(new ThreadStart(tbe.AddTab));...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.