Database Reference
In-Depth Information
Try It: Creating an MDI Parent Form with a Menu Bar
In this exercise, you will create an MDI form in the WinApp project. You will also see how to create a
menu bar for the parent form, which will allow you to navigate to all the child forms. To do so, follow
these steps:
1. Navigate to Solution Explorer, select the WinApp project, right-click, and select
Add Windows form. Change the Name value from Form1.es to ParentForm.es ,
and click Add.
2. Select the newly added ParentForm in the Design view. Select the ParentForm
form by clicking the form's title bar, navigate to the Properties window, and set
the following properties:
a. Set the IsMdiContainer property to True (the default value is False). Notice that the
background color of the form has changed to dark gray.
b. Set the Size property's Width to 546 and Height to 411.
3. Drag a MenuStrip control to the ParentForm. In the top-left corner, you should
now see a drop-down showing text Type Here. Enter the text Open Forms in
the drop-down. This will be your main, top-level menu.
4. Now under the Open Forms menu, add a submenu by entering the text Win
App .
5. Under the Win App submenu, enter User Info .
6. Now click the top menu, Open Forms, and on the right side of it, type Help .
Under the Help menu, enter Exit .
7. Now, click the top menu, on the right side of Help, type Windows .
8. Under the Windows menu, add the following options as separate submenus:
Cascade , Tile Horizontal , Tile Vertical , and Arrange Icons . These will help in
arranging the child forms.
9. Now it's time to attach code to the submenus you have added under the main
menu Open Forms. First, you'll add code for the submenu Win App, which
basically will open the WinApp form. In the Design view, double-click the Win
App submenu, which will take you to the Code view. Under the click event,
add the following code:
WinApp objWA = new WinApp();
objWA.Show();
10. Now to associate functionality with the User Info submenu: double-click this
submenu, and under the click event add the following code:
UserInfo objUI = new UserInfo();
objUI.Show();
To associate functionality with the Exit submenu located under the Help main
menu, double-click Exit, and under the click event add the following code:
Application.Exit();
 
Search WWH ::




Custom Search