So far in this chapter, you have created only single-document interface (SDI) applications. These applications allow a user to work with only one window at a time. Several large Windows applications, such as Microsoft Excel and Visual Studio .NET, allow users to work with several open windows at the same time. These applications are called multiple-document interface (MDI) applications. The main application window of an MDI application acts as the parent window, which can open several child windows. You need to know the following main points about an MDI application:
Child windows are restricted to their parent window (that is, you cannot move a child window outside its parent window).
The parent window can open several types of child windows. As an example of an MDI application, Visual Studio .NET allows you to work with several types of document windows at the same time.
The child windows can be opened, closed, maximized, or minimized independently of each other, but when the parent window is closed, the child windows are automatically closed.
The MDI frame should always have a menu; one of the menus that a user always expects to see in an MDI application is the Window menu (see Figure 2.44), which allows the user to manipulate various windows that are open in an MDI container form.
The Windows Forms in an MDI application are also created by using the standard System.Windows.Forms.Form class. To create an MDI parent form, you create a regular Windows form and change its IsMdiContainer property to true. To create an MDI child form, you create a regular Windows form and assign the name of the parent MDI object to the MdiParent property. Table 2.33 summarizes the important members of the Form class that are related to the MDI applications.
Step by Step 2.22 shows how to create an MDI application. In it you can create a form that is similar to the one created in Step by Step 2.18 and you can use it as an MDI child window.
You learn the following from Step by Step 2.22:
How to create an MDI parent form
How to create MDI child forms
How to convert an existing SDI application to an MDI application
How to merge menus between MDI parent and child windows
How to create Windows menus that allow users to load and rearrange MDI child forms
STEP BY STEP2.22 Creating an MDI Application
|
The default MergeType property for the MenuItem objects is Add. This means that the MenuItem objects in Step by Step 2.22 are added together on an MDI parent window. If you don't want to include some of the menu items, you can set their MergeType properties to Remove. The MergeOrder properties for the MenuItem objects specify the order in which they appear on the parent MDI form.
There is another interesting property of the MenuItem object that is used with MDI applications: the MdiList property. When this property is set to true, the MenuItem object is populated with a list of MDI child windows that are displayed within the associated form.
18.222.210.166