Windows Develop Bookmark and Share   
 index > Windows Forms Designer > Displaying Child forms in a Master form
 

Displaying Child forms in a Master form

Hi all I have an application where I use a Master form with some navigation and then a tab control to display different child forms. When I run the application the child forms are docked in the tab control's pannel like so:

        public void dockFormToControl(Control loadingPanel, Control formToLoad)
        {
            try
            {
                closeForm(loadingPanel);
                ((Form)formToLoad).TopLevel = false;
                loadingPanel.Controls.Add(formToLoad);
                formToLoad.Dock = DockStyle.Fill;
                formToLoad.Show();
            }
            catch (Exception)
            {
            }
        }
This works all fine, I wan't to know if there is a way to attach the child form in the GUI in VS. Like if I go to my master form's design view it must show the basic navigation which it does then when I go to the different tabs it then must show the corresponding child form. Currently it only docks it to the master form at runtime.

Thanks,
DJ
  • Moved byRudedog2 Tuesday, October 06, 2009 12:45 PMWinForms Designer Question (From:Visual C# General)
  •  
DJBruteForce  Tuesday, October 06, 2009 8:31 AM
How can it show any child forms at design time, if you do not attach them until runtime?
You could show a container for the forms at design time, which might be the bet you're going to get.
Mark the best replies as answers. "Fooling computers since 1971."
Rudedog2  Tuesday, October 06, 2009 12:44 PM
I figured as much. I was hoping there might be some form control I can use to set the control's source to my child form then it does all the docking for me at design time and runtime.
DJBruteForce  Tuesday, October 06, 2009 12:49 PM
That concept is called a wrapper. 

Create a custom wrapper container that displays a form.
Make the the contaiiner dockable.  

Add an overloaded constructor that accepts a form as a parameter.
The Designer will only use the public default, parameterless constructor.
Mark the best replies as answers. "Fooling computers since 1971."
Rudedog2  Tuesday, October 06, 2009 1:07 PM

You can use google to search for other answers

Custom Search

More Threads

• Cannot open Designer
• Custom checkbox and radiobutton control
• Replacement of ImageList Collection Editor
• Custom Controls losing Event Handlers and WithEvents
• FormDesigner not available for usercontrol and should be.
• How can MDI parent access controls on the active MDI child form?
• How can Implement a string Collection Editor in a property Grid
• create multiline label
• Inherited Click handler
• Creating Panels when Items are Added in CollectionBase at Designtime