473,322 Members | 1,846 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,322 software developers and data experts.

Can I Add a form as a TabPage

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 on the user selection of a particular function. I would
like to leverage the usefulness of the Form Designer to layout my dialogs and
then load them into TabPages.

I tried setting the TabPage as the Form.Parent and various other things; all
of which would either fail to compile or throw exceptions. I was unable to
find any samples that took this type of approach. I remember in the MFC
world that this was the standard way to develop tabbed dialos.

Any Ideas?

Thanks
Nov 17 '05 #1
6 32034
I found a solution, but it seems like there should be a more elegant way to
do this. This is what I did. I created a TabControl in the form with a
single TabPage that contains all my controls. When I add a new TabPage in my
master form, I instantiate the child form and hand the master TabControl the
TabPage from my child form in the Add() method. I never call Show() on the
child form. Everything displays OK, but I haven't put any code or event
handling in yet to see what traps lie ahead with this.

My goal here is to be able to take advantage of the Form Designer to create
the tab pages that will number around 100 or more and load my TabPages at
runtime based on user input.

Thoughts?

Thanks
Nov 17 '05 #2
On Wed, 18 May 2005 19:52:05 -0700, Sleepy wrote:

Hi Sleepy
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 on the user selection of a particular function. I would
like to leverage the usefulness of the Form Designer to layout my dialogs and
then load them into TabPages.

I tried setting the TabPage as the Form.Parent and various other things; all
of which would either fail to compile or throw exceptions. I was unable to
find any samples that took this type of approach. I remember in the MFC
world that this was the standard way to develop tabbed dialos.


I think the best way would be to do that with usercontrols. For each page
you create a usercontrol where you can put all the required controls to it
in the designer (same way as with forms) and then depending on the users
input you load the corresponding usercontrol in the tabpage.

--
Claudio Grazioli
http://www.grazioli.ch
http://www.grazioli.ch/HommingbergerGepardenforelle/
Nov 17 '05 #3
Thanks Claudio, that is helpful. I had not used the UserControl before this.
This is much better that my first approach.

I see that I have to change the inheritance to TabPage from UserControl in
order to add it to the TabControl. This is fine except that the Designer
then messes up the layout if I open it in the designer while it is inherited
from TabControl.

I just saw a post warning of this and it just said to be careful to change
the inheritance back to UserContriol before entering into the Designer. I
think I can live with this but was just wondering if there is a smoother way
to manage this without having to toggle the inheritance.

Thanks again!
Nov 17 '05 #4
On Thu, 19 May 2005 06:02:05 -0700, Sleepy wrote:
Thanks Claudio, that is helpful. I had not used the UserControl before this.
This is much better that my first approach.

I see that I have to change the inheritance to TabPage from UserControl in
order to add it to the TabControl. This is fine except that the Designer
then messes up the layout if I open it in the designer while it is inherited
from TabControl.

I just saw a post warning of this and it just said to be careful to change
the inheritance back to UserContriol before entering into the Designer. I
think I can live with this but was just wondering if there is a smoother way
to manage this without having to toggle the inheritance.

Thanks again!


I would recommend letting it always inherit from UserControl. And then you
add the usercontrols programmatically to the TabPages (with Dock=Fill).

Then you don't have to switch for and back with what to inherit from when
changing to the designer.

--
Claudio Grazioli
http://www.grazioli.ch
http://www.grazioli.ch/HommingbergerGepardenforelle/
Nov 17 '05 #5
On Thu, 19 May 2005 06:02:05 -0700, Sleepy wrote:
Thanks Claudio, that is helpful. I had not used the UserControl before this.
This is much better that my first approach.

I see that I have to change the inheritance to TabPage from UserControl in
order to add it to the TabControl. This is fine except that the Designer
then messes up the layout if I open it in the designer while it is inherited
from TabControl.

I just saw a post warning of this and it just said to be careful to change
the inheritance back to UserContriol before entering into the Designer. I
think I can live with this but was just wondering if there is a smoother way
to manage this without having to toggle the inheritance.

Thanks again!


I would recommend letting it always inherit from UserControl. And then you
add the usercontrols programmatically to the TabPages (with Dock=Fill).

Then you don't have to switch for and back with what to inherit from when
changing to the designer.

--
Claudio Grazioli
http://www.grazioli.ch
http://www.grazioli.ch/HommingbergerGepardenforelle/
Nov 17 '05 #6
I see, that is much better.

So now I do this:

Project/Add New/User Control
Add my controls to the new UserControl
When it is time to dynamically add my tab page to the TabControl, I do the
following:

TabPage myTabPage = new TabPage(sometext)
myUserControl = new myUserControlType()
myUserControl.Dock = DockStyle.Fill
myTabPage.Controls.Add(myUserControl)
myTabControl.Add(myTabPage);

This works great, thanks again for your help!

Nov 17 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: TMB333 | last post by:
I've researched as much as I can on the issue, but I've not found any clearly defined statement that acknowledges that the Hide method for a TabPage object just doesn't do what it's supposed to do....
8
by: touf | last post by:
Hi, I've a tabcontrol that contains many similar tabpages (exactly the same structure with different information), the tabpages number isn't known in the design time it depends of the data. Is...
4
by: Supra | last post by:
I have a tab control in a which a few of the tabs include an AxWebBrowser browser control. Let say i have currently tabpage2 and i typed url in combobox when i pressed enter it doesn't display...
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...
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...
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: ray well | last post by:
i want a user to be able to change tab pages thru the keyboard, i tried entering the TabPage.text as '&1 Names', "&2 Addresses', etc., so that the user can change pages by type ALT 1, ALT 2, on the...
0
by: mustividyavtahi | last post by:
I am developing a windows application using c# in that i used tabcontrol in MDI form to display the child forms. that is working fine. but my problem is when i click a button in that tabpage (child...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
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...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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...

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.