Click here to Skip to main content
15,794,275 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi All,

I have to design form like
1. Left side of form contains a TreeView
2. On selection of different tree nodes, i want to open different forms on right side of the screen
Which control should i use.
Splitter control is not useful, i cannot open forms in splitter control
is there FRAMESET(Frameset tag in web debelopment) like control exist ? so that i can open forms in it
Any other way ?

Thanks in advnace
Updated 18-Jul-11 1:27am
Sergey Alexandrovich Kryukov 18-Jul-11 14:45pm    
If frameset, this is NOT WinForms! I understood finally what you mean, but it was difficult. Use "Improve question" to word clearly.

Use a SplitContainer. It allows you to split the form vertically or horizontally, and you can get to any control inside the splitter container from the form that contains the container.

You can then put the tree control in one panel, and something else in the other panel.
Share this answer
Sergey Alexandrovich Kryukov 18-Jul-11 14:50pm    
Simple and useful, my 5.
A similar idea I use more: Splitter; please see my solution.
Don't open 'forms' on the right side, load panels (in fact you can probably just use Control). Design your right panels as user controls if you are using a visual IDE to create them, and then you can add them to the right panel of a SplitContainer and set their dock to Fill when the relevant tree node is selected.
Share this answer
Sergey Alexandrovich Kryukov 18-Jul-11 14:51pm    
Good advice, my 5. I use a similar thing, please see my solution.
Use something like AvalonDock[^].

There are similar libraries available for Windows Forms, perhaps:
Visual Studio IDE like Dock Container[^]

Best regards
Espen Harlinn
Share this answer
Sergey Alexandrovich Kryukov 18-Jul-11 14:49pm    
Overkill! However, this is nice approach, so my 5.
By the way, I tried out AvalonDock, found performance is not good. Anything to say about it?

I put my simple solution, please see.
Espen Harlinn 18-Jul-11 17:52pm    
Professionally I use the various DevExpress components, so I've got docking functionality in forms, wpf and silverlight. AvalonDock seems to be the most comprehensive open source solution for WPF, or maybe it's just the best known, I've played around with it a bit, and it seemed to perform adequately ...
Another useful control, more flexible alternative to SplitContainer: System.Windows.Forms.Splitter. I always use this one for splitting. Also, you can develop a custom look for this component as I do, with grip "dimples".

Share this answer
Espen Harlinn 18-Jul-11 17:53pm    
Yes, this can also be an elegaant solution - my 5
Sergey Alexandrovich Kryukov 18-Jul-11 18:05pm    
Thank you, Espen.
Dock your TreeView on the left side of an MDI Form's client area and open the forms inside the MDI form on the TreeView's NodeClick event.
Share this answer
manavya 18-Jul-11 6:19am    
Thanks for reply.
can i access controls of child form from MDI form ???
dan!sh 18-Jul-11 6:24am    
No. And you should not controls public. Make use of properties and delegates for data transfer.
[no name] 18-Jul-11 14:50pm    
You can, but you should not. But if you misunderstood my answer, the TreeView resides in the MDI form and on its NodeClick event, you show/hide the child forms.
Sergey Alexandrovich Kryukov 18-Jul-11 14:51pm    
Listen to a good friendly advice: never ever use MDI. It is deprecated and discouraged even (or foremost) by Microsoft. Don't torture yourself and repel users.
[no name] 18-Jul-11 14:52pm    
I haven't read anywhere that it is deprecated. Can you give me some links?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900