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

Dynamic views

Hi,

I'm writing a windows explorer like application. The GUI
is divided by a vertical splitter. To the left I have a
tree control. To the right of the splitter I would like
to display one of several different user controls
according to what is selected in the tree control. Now, I
can do this by placing all of my different user controls
on the form and then use .Show() and .Hide() on the
controls. However, I do not fancy this technique, Isn't
there a more elegant way of doing this.

Another thing, If I instantiate these user controls
dynamically and place them on the form, should they be
placed on a panel?. Where should I store the reference to
the user control.

Thank you in advance.
Best regards Jesper.
Nov 15 '05 #1
4 5999
Hey Jesper,

I do this exact same thing in several of my programs. There is a list of
'commands', each has its own GUI interface so there is a spot where the
correct control plugs in. Here are some things to consider:

1. It would be a good idea, but not required, to make one UserControl
control that is a basic version of the plug-in control. Then the specific
plug-ins can all be extended from your 'template' instead of UserControl.
This gives you more control over how they look and interact.

2. Yes, put a panel where you want the controls to go, it makes things a
little easier. Let's call it 'pnlHost'. All you really need to do is look
at the Windows Designer Generate Code to see how controls are added via
code. I'll give you what you need here.

private void ShowControl(UserControl c)
{
pnlHost.Controls.Clear(); // Remove any current controls in the panel
pnlHost.Controls.Add(c); // Put the special control in the host panel
c.Dock = DockStyle.Fill; // Make the control fill the host panel
}

Then say you have a custom control called "PageSettings", you want to show
it in the host panel, just call: ShowControl(new PageSettings());

That's practically all there is to it!

Good luck!

-Noah Coad
Microsoft MVP & MCP [.NET/C#]

"Jesper DK" <je****@hotmail.com> wrote in message
news:03****************************@phx.gbl...
Hi,

I'm writing a windows explorer like application. The GUI
is divided by a vertical splitter. To the left I have a
tree control. To the right of the splitter I would like
to display one of several different user controls
according to what is selected in the tree control. Now, I
can do this by placing all of my different user controls
on the form and then use .Show() and .Hide() on the
controls. However, I do not fancy this technique, Isn't
there a more elegant way of doing this.

Another thing, If I instantiate these user controls
dynamically and place them on the form, should they be
placed on a panel?. Where should I store the reference to
the user control.

Thank you in advance.
Best regards Jesper.

Nov 15 '05 #2
Hey Jesper,

I do this exact same thing in several of my programs. There is a list of
'commands', each has its own GUI interface so there is a spot where the
correct control plugs in. Here are some things to consider:

1. It would be a good idea, but not required, to make one UserControl
control that is a basic version of the plug-in control. Then the specific
plug-ins can all be extended from your 'template' instead of UserControl.
This gives you more control over how they look and interact.

2. Yes, put a panel where you want the controls to go, it makes things a
little easier. Let's call it 'pnlHost'. All you really need to do is look
at the Windows Designer Generate Code to see how controls are added via
code. I'll give you what you need here.

private void ShowControl(UserControl c)
{
pnlHost.Controls.Clear(); // Remove any current controls in the panel
pnlHost.Controls.Add(c); // Put the special control in the host panel
c.Dock = DockStyle.Fill; // Make the control fill the host panel
}

Then say you have a custom control called "PageSettings", you want to show
it in the host panel, just call: ShowControl(new PageSettings());

That's practically all there is to it!

Good luck!

-Noah Coad
Microsoft MVP & MCP [.NET/C#]

"Jesper DK" <je****@hotmail.com> wrote in message
news:03****************************@phx.gbl...
Hi,

I'm writing a windows explorer like application. The GUI
is divided by a vertical splitter. To the left I have a
tree control. To the right of the splitter I would like
to display one of several different user controls
according to what is selected in the tree control. Now, I
can do this by placing all of my different user controls
on the form and then use .Show() and .Hide() on the
controls. However, I do not fancy this technique, Isn't
there a more elegant way of doing this.

Another thing, If I instantiate these user controls
dynamically and place them on the form, should they be
placed on a panel?. Where should I store the reference to
the user control.

Thank you in advance.
Best regards Jesper.

Nov 15 '05 #3
Thanks Noah

Could you clarify point 1. Provide a link to a sample
perhaps. I would like to learn to do it right.

Thanks and best regards.
Jesper
-----Original Message-----
Hey Jesper,

I do this exact same thing in several of my programs. There is a list of'commands', each has its own GUI interface so there is a spot where thecorrect control plugs in. Here are some things to consider:
1. It would be a good idea, but not required, to make one UserControlcontrol that is a basic version of the plug-in control. Then the specificplug-ins can all be extended from your 'template' instead of UserControl.This gives you more control over how they look and interact.
2. Yes, put a panel where you want the controls to go, it makes things alittle easier. Let's call it 'pnlHost'. All you really need to do is lookat the Windows Designer Generate Code to see how controls are added viacode. I'll give you what you need here.

private void ShowControl(UserControl c)
{
pnlHost.Controls.Clear(); // Remove any current controls in the panel pnlHost.Controls.Add(c); // Put the special control in the host panel c.Dock = DockStyle.Fill; // Make the control fill the host panel}

Then say you have a custom control called "PageSettings", you want to showit in the host panel, just call: ShowControl(new PageSettings());
That's practically all there is to it!

Good luck!

-Noah Coad
Microsoft MVP & MCP [.NET/C#]

"Jesper DK" <je****@hotmail.com> wrote in message
news:03****************************@phx.gbl...
Hi,

I'm writing a windows explorer like application. The GUI is divided by a vertical splitter. To the left I have a
tree control. To the right of the splitter I would like
to display one of several different user controls
according to what is selected in the tree control. Now, I can do this by placing all of my different user controls on the form and then use .Show() and .Hide() on the
controls. However, I do not fancy this technique, Isn't
there a more elegant way of doing this.

Another thing, If I instantiate these user controls
dynamically and place them on the form, should they be
placed on a panel?. Where should I store the reference to the user control.

Thank you in advance.
Best regards Jesper.

.

Nov 15 '05 #4
Thanks Noah

Could you clarify point 1. Provide a link to a sample
perhaps. I would like to learn to do it right.

Thanks and best regards.
Jesper
-----Original Message-----
Hey Jesper,

I do this exact same thing in several of my programs. There is a list of'commands', each has its own GUI interface so there is a spot where thecorrect control plugs in. Here are some things to consider:
1. It would be a good idea, but not required, to make one UserControlcontrol that is a basic version of the plug-in control. Then the specificplug-ins can all be extended from your 'template' instead of UserControl.This gives you more control over how they look and interact.
2. Yes, put a panel where you want the controls to go, it makes things alittle easier. Let's call it 'pnlHost'. All you really need to do is lookat the Windows Designer Generate Code to see how controls are added viacode. I'll give you what you need here.

private void ShowControl(UserControl c)
{
pnlHost.Controls.Clear(); // Remove any current controls in the panel pnlHost.Controls.Add(c); // Put the special control in the host panel c.Dock = DockStyle.Fill; // Make the control fill the host panel}

Then say you have a custom control called "PageSettings", you want to showit in the host panel, just call: ShowControl(new PageSettings());
That's practically all there is to it!

Good luck!

-Noah Coad
Microsoft MVP & MCP [.NET/C#]

"Jesper DK" <je****@hotmail.com> wrote in message
news:03****************************@phx.gbl...
Hi,

I'm writing a windows explorer like application. The GUI is divided by a vertical splitter. To the left I have a
tree control. To the right of the splitter I would like
to display one of several different user controls
according to what is selected in the tree control. Now, I can do this by placing all of my different user controls on the form and then use .Show() and .Hide() on the
controls. However, I do not fancy this technique, Isn't
there a more elegant way of doing this.

Another thing, If I instantiate these user controls
dynamically and place them on the form, should they be
placed on a panel?. Where should I store the reference to the user control.

Thank you in advance.
Best regards Jesper.

.

Nov 15 '05 #5

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

Similar topics

8
by: Ashish Shridharan | last post by:
Hi All I have been trying to add a control to the header cell of a datagrid on my ASP.NET page. These controls are defined in the HTML as ASP.NET web controls. They are being added into the...
5
by: traceable1 | last post by:
I am trying to create a stored procedure with dynamic sql referencing the V$SESSION table (view). I need to use this dynamically, because the procedure will not compile if the user does not have...
4
by: MD | last post by:
I am trying to create a dynamic SQL statement to create a view. I have a stored procedure, which based on the parameters passed calls different stored procedures. Each of this sub stored procedure...
2
by: yzarc | last post by:
I'm working with a DB design that seems to me to be rather complex. This is a very slimmed down version of what I'm doing, but I believe it is enough to get my question resolved. Here is my...
3
by: KemperR | last post by:
Hello Experts outhere, may be someone can tell me whats going wrong with my ADOX trial. I have an Access 2002 database with some tables and queries (views) The code listed below works well up...
3
by: sferriol | last post by:
hello is it possible with postgres 7.2 or more, to define a dynamic view. For example, i have a table with a column 'user' and i want to define a view which gives infomrations from different...
0
by: eric.olstad | last post by:
I want to create a web site that can dynamically creates tabs -- like firefox functionality built into a web site. Take a look at this site to get an idea of what I'm looking to do:...
9
by: pbd22 | last post by:
Hi. This is just a disaster management question. I am using XMLHTTP for the dynamic loading of content in a very crucial area of my web site. Same as an IFrame, but using XMLHTTP and a DIV. I...
14
by: asdf | last post by:
I have a python script whose output i want to dynamically display on a webpage which will be hosted using Apache. How do I do that? thanks
21
by: arnuld | last post by:
I have created a program to print the input words on stdout. Input is taken dynamically from stdin. In each word, each input character is allocated dynamically. I have ran this program with a file...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...
0
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
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
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,...

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.