Changes

Jump to: navigation, search

Creating a Visual Basic MDI Form

1,581 bytes added, 17:08, 23 July 2007
no edit summary
[[Image:Exampl.jpg]]
 
== Creating an MDI Parent and Child Forms in Visual Studio ==
 
The first step in creating an MDI form is to create the parent form. Begin by launching Visual Studio and creating a new ''Windows Application'' project named ''vbMDI''. The new project will contain a single form. Change the name of this form in the ''Properties'' panel to ''MDIparent''. Also in the ''Properties'' panel, change the ''IsMdiContainer'' property to ''True''. You will notice that the form background changes to dark grey, the default for MDI containers. This form is now ready to act as the container for the child forms.
 
Add two more forms to the project using the Visual Studio ''Add New Item'' toolbar button:
 
[[Image:Exampl.jpg]]
 
Edit the properties of the two new forms so that the title texts are ''Child Form 1'' and ''Child Form2'' repectively. Also, use the properties panel to name the forms ''MDIchild1'' and ''MDIchild2''.
 
== Writing the Visual Basic Code to Add the Children to the MDI Parent ==
 
The next step is to add the two new forms (''''MDIchild1'' and ''MDIchild2'') to the parent form (''MDIparent''). TO do this click on the tab for the parent form in Visual Studio and double click on the form to display the event procedures. We will now write Visual Basic code to add the two child forms to the container parent form. To do this we will set the ''MdiParent'' property of each child to reference the 'MDIparent'' form. Note that because this is the load event of the actual parent form, we refer top it with the keyword ''Me'' rather than by the form name:
 
<pre>
 
</pre>

Navigation menu