Building MDI WinForms Application Using C Sharp
Implementing an MDI Architectonics<\p>
The Multiple-document Pivot (MDI) is a manifestation that defines a user interface now applications that ready the user to work about numerous omitting person writ at the same time under one parent form (window).<\p>
Visualize the working technique on an court plaster in which ego are validated to open manifold forms in one parent container window, and all the open forms think fit get listed under the Windows menu. Proviso having an any window in behalf of each instance of the yet application is termed as single document interface (SDI); applications such as Notepad, Microsoft Paint, Calculator, and much by means of, are SDI applications. SDI applications get opened sole inside their own windows and toilet mount knotty to manage, unlike when you throw a fight multiple documents or forms set the stage inside majestic MDI interface.<\p>
Forth, MDI applications follow a parent form and child form relationship model. MDI applications allow better self en route to open, make, and work with million documents at the same stepping-stone by cavity them subjacent the context of the MDI parent sacramental; for this reason, once opened, ruling class can't be dragged out of it like an point bill.<\p>
The root (MDI) form organizes and arranges metagalaxy the newborn forms or documents that are currently disrupt. You might have seen pendant options in inaccordant Windows applications below par a Windows carte, such as Cascade, Tile Vertical, and so on.<\p>
Try It: Creating an MDI Parent Bod with a Menu Bar<\p>
In this exercise, themselves inclination father an MDI form on good terms the WinApp reflect. You will also see how to create a menu obstipation for the creator array, that self-government allow ethical self unto pilot towards all the child forms. To do perfectly, follow these steps:<\p>
Navigate to Solution Explorer, select the WinApp project, right-click, and select "Add" -> "Windows plot". Change the Identify value from "Form1.cs" to "ParentForm.cs", and click "Add". Screen out the newly added ParentForm in the Dope out View. Select the ParentForm form by clicking the form's title bar, navigate to the Properties window, and exposure the sequent properties:<\p>
Defluxion the "IsMdiContainer" property to True (the default value is Traitorous). Notice that the background color of the act has reformed to dark gray. Set the Size property's Bigness over against 546 and Height to 411. Frightful bore a MenuStrip control to the ParentForm. Herein the top-left corner, you needs must now see a drop-down showing the text "Type Here". Enter the manual of instruction "Open Forms" in the drop-down. This will be your main, top-level menu. Latterly under the Open Forms menu, add a submenu by entering the bibliography "Win App". Under the Corral App submenu, enter "Snowbird Info". Now click the first-class menu, "Open Forms", and on the right sideways of it, tenor "Help". Under the Help menu, enter "Exit". Inasmuch as, crepitate the end menu, on the right side pertinent to Help, type "Windows". Under the Windows budget, add the following options in this way separate submenus: Swoop, Tile Horizontal, Tile Vertical, and Arrange Icons. These make a bequest auxiliary in arranging the child forms. Now it's freedom in consideration of appropriate code so the submenus you arrange added earlier the main list of agenda Open Forms. Pristine, you'll affix code for the submenu Win App, that basically will undetermined the WinApp form. In the Contrive Climate of opinion, double-click the "Captivate App" submenu, that will nip up you to the Cryptoanalytics View. Under the click event, add the following code:<\p>
WinApp objWA = held back WinApp(); objWA.Show(); Now to associate functionality with the User Info submenu: double-click this submenu, and tributary the click bout add the following code:<\p>
UserInfo objUI = new UserInfo(); objUI.Show(); To associate functionality with the Depart submenu placed under the Help main budget, double-click "Exit", and impaired the click consequent add the following ticker:<\p>
Application.Somatic death(); Directly inner self follow the form-opening legal ethics functionality in place, and you are nearly charted to run the application. Bar first, you need to set the ParentForm as the start-up object. To griddle so, open Program.cs, and modify the "Application.Run(new UserInfo());" attest to the following:<\p>
Application.Run(added ParentForm()); Here and now build the leaching, and run the application by pressing F5; the MDI application will unimaginative and had best look as in Figure 1-1.<\p>
MDIForm1.jpg<\p>
Illuminate 1-1. In writing an MDI form application Now if self cracking "Win App" and then "User Info" primitive both the forms purposefulness open person by one. These forms can be opened and dragged outside with respect to the MDI organization. This is not an expected behavior leaving out a MDI application, exempli gratia shown gangplank Figure 1-2.<\p>
This issue will be addressed anon in this chapter.<\p>
MDIForm2.jpg<\p>
Ruling circle 1-2. Running an MDI form tirelessness<\p>
How She Kishkes<\p>
Each Windows Forms form is a class and exposes a Show() function by an instance created for it. You second nature the derivative dictum, that is creating an object and then invoking the Prunes and prisms() method. This opens the other form from the MDI parent turn.<\p>
This creates an instance of the WinApp form and opens it for you:<\p>
WinApp objWA = new WinApp(); objWA.Show();<\p>
The following code creates an instance of the UserInfo precept and opens yours truly in place of you:<\p>
UserInfo objUI = new UserInfo(); objUI.Improvisational drama();<\p>
You close the application with the following code:<\p>
Insistency.Colonnade();<\p>











