Lesson 09 Working with SDI and MDI MIT 31043: Rapid Application Development By: S. Sabraz Nawaz Senior Lecturer in MIT Dept. of MIT, FMC, SEUSL
Single Document Interface (SDI) An SDI application that consists of more than one form can begin with a startup form that directs the user to the other forms of the application. A form that s displayed from a startup form should contain a Close button rather than an Exit button to indicate that the button will close the form and not exit the application and close all open forms. By:MIT 31043 by SaNa @SEUSL 2
Single Document Interface (SDI) When the user clicks the shownewformbutton, the first statement creates a new instance of the newstudententry form. Then the Show method of the form is executed to load and display the form. By:MIT 31043 by SaNa @SEUSL 3
To add a Form title with counting By:MIT 31043 by SaNa @SEUSL 4
Creating Menus By:MIT 31043 by SaNa @SEUSL 5
MenuStrip Control To provide access to the functions of an application, you can add menus to a form. Menus sometimes duplicate the functionality that s already available from the buttons and other controls of a form, but they can also provide access to functions that aren t available anywhere else. 6
Adding Your Own Menus To add a menu item, click the box labeled Type Here and type the name of the menu. You will notice that as you type, another box will appear beside and below it so you can add more items. As an example, type File, Edit, and Help in the MenuStrip. To add submenus, click a menu item it will open up a container for all its submenus. You will also see a box that will allow you to insert sub menus. If you want to add a separator, type the character. You can even create submenus of submenus. You can nest and nest menus if you want to. A submenu which contains another submenu can be identified by the arrow at its right side. 7
Adding Standard Menus Click on the arrow button at the upper right side of the MenuStrip. Then choose Insert Standard Items. Visual Studio will fill the MenuStrip with standard menus such as Creating New files, Saving Files, Loading and many more. 8
Adding Shortcut Keys to a Menu Item If you want complex shortcut combinations, then we have to use the ShortcutKeys property. Select a menu item and then go to the Properties Window and find the ShortcutKeys property. Click the drop down arrow to show you a small window that allows you to choose the shortcut keys for the current menu item. 9
Adding Icons to Menu Items You can add images or icons at the left side of a menu item as seen in the standard menus. We use the Image property to do just that. Click the drop down button of the Image property in the Property Window. Choose which resource to use and then browse for the appropriate image. If the image is too large, then it will automatically be scaled based on the value of the ImageScaling property. 10
Multiple Document Interface (MDI) By:MIT 31043 by SaNa @SEUSL 11
MDIs If the application you are developing requires multiple instances of one or more forms, you may want to use Multiple Document Interface (MDI). You can create a parent form that acts as a container for all of the child forms. You can provide menu to make it easier to display and manage the child forms. By:MIT 31043 by SaNa @SEUSL 12
To change a form as MDI container Set these Property IsMdiContainer WindowState Value True Maximized To show an existing form (another form) under an MDI Double click the relevant menu and add the following code By:MIT 31043 by SaNa @SEUSL 13
Arranging child windows By:MIT 31043 by SaNa @SEUSL 14
To list windows under MDI Click on the MenuStrip. And set its MdiWindowListItem property. By:MIT 31043 by SaNa @SEUSL 15
Creating a simple login form By:MIT 31043 by SaNa @SEUSL 16
Passing login data between forms Step I: declare the variable in MDI Parent Step II: Pass the parameter in the Login form s OK click event By:MIT 31043 by SaNa @SEUSL 17
Passing login data between forms Step III: Instantiate MDI Parent with the value By:MIT 31043 by SaNa @SEUSL 18
To close all forms and MDI itself By:MIT 31043 by SaNa @SEUSL 19
Thank you By:MIT 31043 by SaNa @SEUSL 20