Windows Develop Bookmark and Share   
 index > Windows Forms General > How to use SplitContainer properly?
 

How to use SplitContainer properly?

In my main application, the user can create MDI child forms of a certain class I have created (the class is ChatWindow, which inherits from Form). I spawn one or two of these at certain times, and make them MDI children of the parent form. At a certain point in my program, I open up a panel on the right side, which contains a number of controls for displaying key things about the program; this panel covers the screen vertically and extends from the right side about 200 pixels or so.

I want the user to be able to click and drag this panel left and right, increasing/decreasing its size. It seems like the SplitContainer is the perfect way to do this... except that I can no longer spawn forms and have them floating around to the left of the panel (ie, I cannot add Forms to splitContainer.Panel1).

How can I do this properly? I want to divide the parent form into two vertical halves; the left half will have one or two MDI forms spawned in it, and the right half will contain controls, and will be horizontally resizable. Can I use SplitContainer to accomplish this? Currently, I just have a Panel object with panel.Dock = Right, but it is obviously not resizable.
Ricky Pusch  Sunday, May 04, 2008 7:05 AM
After doing a bit of googling, I managed to find a solution which does do its own resizing. It is here for anyone in the future who reads this topic and wants a solution:

http://www.developerfusion.co.uk/show/1787/1/

It actually works really well! I just put my one big panel in the docking control, set the panel's Dock to Fill, and then I can drag the docking control around and it works like I was hoping. It has to dock on a Form, though... you can't dock a control within a control (like a Panel), so this may limit its use, but it does the job for me.
Ricky Pusch  Monday, May 05, 2008 6:58 AM

Right, the MDI children have to be in the MDIControl. This is the control that has the gray background in the MDI parent and hosts child forms, but you can't select and modify it in the designer.

You can, however, access it in the code, as it is a member of the MDI parent form's controls collection.

Perhaps it would be possible to programmatically remove the mdicontrol from the form, add a splitcontainer, and then place the mdicontrol inside the left panel.

This is undoubtedly a big can of worms.

I'd suggest using a panel on the right and creating the for resizing yourself. It is a bit of a pain, but so will be the above.

JayStation3  Monday, May 05, 2008 3:35 AM
After doing a bit of googling, I managed to find a solution which does do its own resizing. It is here for anyone in the future who reads this topic and wants a solution:

http://www.developerfusion.co.uk/show/1787/1/

It actually works really well! I just put my one big panel in the docking control, set the panel's Dock to Fill, and then I can drag the docking control around and it works like I was hoping. It has to dock on a Form, though... you can't dock a control within a control (like a Panel), so this may limit its use, but it does the job for me.
Ricky Pusch  Monday, May 05, 2008 6:58 AM

You can use google to search for other answers

Custom Search

More Threads

• BackGroundImage & Performance
• What should localized RESX files contain
• how do you find the tag of a clicked menu item
• Hot tracking in listbox
• Cannot focus on a control that has CanFocus = True
• How to get an invisible WebBrowser's content as an image?
• Intercepting keydown "Delete"
• ListView Control Problems
• treeview click event
• Specific Panel to scroll always