473,326 Members | 2,012 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,326 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 5992
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: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
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...
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...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
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: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
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
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.