Database Reference
In-Depth Information
Figure 9-21. Opening child forms inside an MDI form application
5. Because both the forms are open inside one MDI parent, it becomes easier to
work with them, and they are not draggable outside of MDI parent. Switch
back and forth between these forms by clicking their title bars.
6. Once you are done with the forms, close the application by selecting Help
Exit.
How It Works
As you noticed in earlier exercise, the only issue discussed was that child forms opened and were able to
be dragged outside. In other words, they didn't really belong to a parent form. An MDI application is
about claiming a form with a menu bar as an MDI parent so all the child forms can open inside it.
To do so, first an object of the child form needs to be created:
WinApp objWA = new WinApp();
But before we really invoke the Show() method on the objWA , you need to tell the object who is its
parent so it operates from within the MDI parent form. To accomplish this, you will use the this
keyword, which represents the current form class.
objWA.MdiParent = this;
You have object created and its context set to MDI parent form, so now it's a perfect time to call
Show() method, which will launch the form so you can work with it.
 
Search WWH ::




Custom Search