11
How to Create MDI Applications Contents Introduction .................................................................................................................................................. 1 Create MDI Parent ........................................................................................................................................ 1 Load Child Forms........................................................................................................................................... 2 Load a child by menu ................................................................................................................................ 2 Load a child from another child ................................................................................................................ 6 Test................................................................................................................................................................ 9 Feedback ..................................................................................................................................................... 11 Introduction A MDI (Multiple-Document-Interface) application uses one form as a parent to load many forms as its child forms. Create MDI Parent To make a form to be a MDI parent, set its IsMDIContainer property to True. All other forms can be MDI child forms. Usually a menu strip is added to a MDI parent to load child forms:

How to Create MDI Applications - · PDF fileHow to Create MDI Applications ... set its IsMDIContainer property to True. All other forms can be MDI ... Load Child Forms To load a form

Embed Size (px)

Citation preview

Page 1: How to Create MDI Applications - · PDF fileHow to Create MDI Applications ... set its IsMDIContainer property to True. All other forms can be MDI ... Load Child Forms To load a form

HowtoCreateMDIApplications

Contents Introduction .................................................................................................................................................. 1

Create MDI Parent ........................................................................................................................................ 1

Load Child Forms ........................................................................................................................................... 2

Load a child by menu ................................................................................................................................ 2

Load a child from another child ................................................................................................................ 6

Test ................................................................................................................................................................ 9

Feedback ..................................................................................................................................................... 11

Introduction

A MDI (Multiple-Document-Interface) application uses one form as a parent to load many forms as its

child forms.

Create MDI Parent

To make a form to be a MDI parent, set its IsMDIContainer property to True. All other forms can be MDI

child forms.

Usually a menu strip is added to a MDI parent to load child forms:

Page 2: How to Create MDI Applications - · PDF fileHow to Create MDI Applications ... set its IsMDIContainer property to True. All other forms can be MDI ... Load Child Forms To load a form

Add some menu items for loading child forms:

Load Child Forms

To load a form into a MDI parent as its MDI child form, you need to execute two actions: the form’s

Show action and set the form’s MDIParent property to the MDI parent form.

Load a child by menu

Suppose we want to load Form2 when menu “Form2” is selected; load Form3 when menu “Form3” is

selected.

Right-click menu “Form2” in the Event Map; choose “Assign Actions”; choose “Click” event:

Select Show method of the default instance of Form2 and click Next:

Page 3: How to Create MDI Applications - · PDF fileHow to Create MDI Applications ... set its IsMDIContainer property to True. All other forms can be MDI ... Load Child Forms To load a form

Click OK to create the action:

The action is created and assigned to the menu event:

We need to execute another action to set MDI parent of Form2. Right-click the Click event of the menu;

choose “Assign actions”:

Page 4: How to Create MDI Applications - · PDF fileHow to Create MDI Applications ... set its IsMDIContainer property to True. All other forms can be MDI ... Load Child Forms To load a form

Choose MDIParent property of the default instance of Form2; click Next:

Select “Property” to choose MDI parent:

Select the MDI parent form and click Next:

Page 5: How to Create MDI Applications - · PDF fileHow to Create MDI Applications ... set its IsMDIContainer property to True. All other forms can be MDI ... Load Child Forms To load a form

Click OK to create the action:

The action is created and assigned to the menu event:

In the same process as described above, we may do the programming for menu “Form3”:

Page 6: How to Create MDI Applications - · PDF fileHow to Create MDI Applications ... set its IsMDIContainer property to True. All other forms can be MDI ... Load Child Forms To load a form

Load a child from another child

Suppose we have button on Form2. Click the button will load Form3 as a MDI child.

Right-click the button on Form2; choose “Assign Actions”; choose “Click” event:

Select Show method of the default instance of Form3 and Click Next:

Click OK to finish creating the action:

Page 7: How to Create MDI Applications - · PDF fileHow to Create MDI Applications ... set its IsMDIContainer property to True. All other forms can be MDI ... Load Child Forms To load a form

The action is created and assigned to the button:

Add another action to set Form3’s MDIParent to Form1:

Select MDIParent property of the default instance of Form3:

Page 8: How to Create MDI Applications - · PDF fileHow to Create MDI Applications ... set its IsMDIContainer property to True. All other forms can be MDI ... Load Child Forms To load a form

Select “Property” and then select the default instance of Form1:

Page 9: How to Create MDI Applications - · PDF fileHow to Create MDI Applications ... set its IsMDIContainer property to True. All other forms can be MDI ... Load Child Forms To load a form

Click OK to create the action:

The action is created and assigned to the button:

Test

We may test the MDI application now:

Page 10: How to Create MDI Applications - · PDF fileHow to Create MDI Applications ... set its IsMDIContainer property to True. All other forms can be MDI ... Load Child Forms To load a form

The MDI parent form, Form1, appears. Select menu Form2:

Form2 appears as a child form:

Select menu Form3:

Form3 appears as a child form:

Page 11: How to Create MDI Applications - · PDF fileHow to Create MDI Applications ... set its IsMDIContainer property to True. All other forms can be MDI ... Load Child Forms To load a form

Form3 may also be loaded by click the button on Form2:

Feedback

Please send your feedback to [email protected]. Thanks!