Database Reference
In-Depth Information
In this exercise, you will overcome this problem and associate all the forms you created earlier as
MDI child forms to the main MDI parent form you created in the previous task.
1. In the project you modified in the previous exercise, you'll first make the
WinApp form an MDI child form. To do so, you need to set the MdiParent
property of the child form's object to the MDI parent form itself, but in the
Code view. You have already added functionality in the previous task (opening
the WinApp form); just before the line where you are calling the Show()
method, add the following code (this code can be found under Win App menu
click event):
objWA.MdiParent=this;
After adding this line, the code will appear as follows:
WinApp objWA = new WinApp();
objWA.MdiParent = this;
objWA.Show();
Note this is a C# language keyword that represents the current instance of the class. In this case, it refers to
ParentForm. Because you are writing this code inside ParentForm, you can use the this keyword for the same.
2. Now you will make the UserInfo form an MDI child form. To do so, you need
to set the MdiParent property to the name of the MDI parent form but in the
Code view. Add the following code as you did in the previous step (this code
can be found under the User Info menu click event):
objUI.MdiParent=this;
After adding this line, the code will appear as follows:
UserInfo objUI = new UserInfo();
objUI.MdiParent=this;
objUI.Show();
3. Now build the solution, and run the application by pressing F5; the MDI
application will open and should appear as shown in Figure 9-21.
4. Click Open Form Win App; the WinApp form should open. Again, open the
main menu and click User Info. Both the forms should now be open inside
your main MDI parent form application, and unlike before, you will not be
able to drag these out of your MDI parent form (as shown in Figure 9-20).
Figure 9-21 shows the expected behavior of an MDI application with opened
form(s).
Search WWH ::




Custom Search