473,503 Members | 1,700 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Forms Designer and Dynamic Panels

I have a situation similar to what you see in Visual Studio Options
menu. A Tree View on the left, and depending on what type of node you
click it dynamically loads a panel into the right hand side of the
form.

It would be really nice if I could design all possible right hand side
panels in the forms designer, then have some way to tell the framework
"load the form represented by the class SuchAndSuchForm". What I have
to resort to currently is this:

1) Drop a panel into the right hand side of my main form.
2) Drop all the controls onto it and lay it out and everything
3) Manually edit the InitializeComponent() method and strip out all the
designer generated code into a separate method. Also remove the part
that calls Controls.Add()

This is very annoying, because I might have like 10 different types of
page I want to display on the right hand side. Not only is it a
headache stripping out code from the InitializeComponent() method that
many times, but if I want to make a change later to the layout of that
dynamic panel, it's not in the designer anymore.

I tried also making a totally new form and then change the base class
to derive from Panel instead of Form, but then it's not available in
the designer. If I could do that, then I could simply create a new
instance of that custom class type in the constructor. I also tried
leaving it as base class Form, but Form doesn't have a Dock attribute
which I would like to set to Fill since I use a splitter in the middle.

You'd think this would be a fairly common paradigm, Visual Studio
itself uses it.

Any suggestions?
Thanks

Feb 10 '06 #1
2 3203
Hey Zach,

Looks like what you're problem can be easily solved using UserControls.
This way you can create a user control for each type of "page" you are
wanting to show depending on the treeview node selected. I would recommend
either adding several of those to your project, of if you're looking to
inherite from the Panel control and are using VS 2005 you can also use
Inherited User Controls. Here is a link to a user control page that might
help get you started. Hope this helps!

http://msdn.microsoft.com/library/de...ogypreview.asp

"Zach" wrote:
I have a situation similar to what you see in Visual Studio Options
menu. A Tree View on the left, and depending on what type of node you
click it dynamically loads a panel into the right hand side of the
form.

It would be really nice if I could design all possible right hand side
panels in the forms designer, then have some way to tell the framework
"load the form represented by the class SuchAndSuchForm". What I have
to resort to currently is this:

1) Drop a panel into the right hand side of my main form.
2) Drop all the controls onto it and lay it out and everything
3) Manually edit the InitializeComponent() method and strip out all the
designer generated code into a separate method. Also remove the part
that calls Controls.Add()

This is very annoying, because I might have like 10 different types of
page I want to display on the right hand side. Not only is it a
headache stripping out code from the InitializeComponent() method that
many times, but if I want to make a change later to the layout of that
dynamic panel, it's not in the designer anymore.

I tried also making a totally new form and then change the base class
to derive from Panel instead of Form, but then it's not available in
the designer. If I could do that, then I could simply create a new
instance of that custom class type in the constructor. I also tried
leaving it as base class Form, but Form doesn't have a Dock attribute
which I would like to set to Fill since I use a splitter in the middle.

You'd think this would be a fairly common paradigm, Visual Studio
itself uses it.

Any suggestions?
Thanks

Feb 10 '06 #2
This worked well, thansk for your advice. The problem I run into now
is that I'd like the dynamic panel on the right of the tree view to
fill the area on the right hand side. The tree view and right hand
side are separated by a splitter and when the splitter is adjusted I'd
like for the right hand side to adjust as well. Normally what I'd do
is simply set the Dock property of the right hand side to
DockStyle.Fill. There is no designer support apparently for setting
DockProperty of a UserControl, but I just went ahead and set it
manually in code to DockStyle.Fill. It fills the entire page, not just
the part to the right of the splitter, and the tree view and splitter
are drawn on top of part of the dynamic panel. Is there any way to get
this to behave the way I would expect? For reference, TreeView.Dock =
Left, Splitter.Dock = Left, RightHandSidePanel.Dock = Fill

Feb 13 '06 #3

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

Similar topics

6
2223
by: Patrick Coghlan | last post by:
I want to create about 4 forms with the same dimensions and background colours, similar to the forms one has to traverse when installing various software packages. I'm using Visual Studio and...
6
517
by: Manny Chohan | last post by:
I am using forms authetication in the web config. i can validate a user against a database and click on images which makes hidden panels visible.However when i click on the link inside a panel...
7
2454
by: Mike Bulava | last post by:
I have created a base form that I plan to use throughout my application let call the form form1. I have Built the project then add another form that inherits from form1, I add a few panel controls...
6
2309
by: | last post by:
Just a general question... When working with a form containing a treeview or similar control... if you need to show different form fields depending on what is selected in the treeview then what...
0
7087
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7281
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7334
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6993
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5579
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5014
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
4675
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
1514
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
383
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.