How to create a WinForms MDI application? - part 4
By ganton ~ July 25th, 2008. Filed under: WinForms.
It is my last post of the series. The post before this focused on the custom classes developed to support Presentation Layer of the sample application. A group of classes of input data validation has been presented. Another two classes for managing forms and central managing of exceptions were provided.
(All posts in this series: Post 1, Post 2, Post 3, Post 4, Source Code)
Today, I’ll present the rest of the sample application.You can have look at application file structure on the picture below.
Application classes and forms’ classes are logically grouped in different folders. In the reports folder we have a CrystalReports template file with the report view needed to present maintenance done of the individual car and a form which displays the report. Next up is Common folder that groups base classes described in my third post of the series. BaseForm is described below. We come to CarManagement folder that groups two forms classes one for listing all cars and one for managing new and existing cars. The last folder is CarMaintenanceManagement that contains forms related to cars’ maintenance management.
As I mentioned in my previous posts it is a sample of MDI application. Consequently, we need a windows form to be a MDI container (MDI parent form). MainForm form is the MDI container in this application. All forms are opened into it except of ManageCarForm, ManageCarMaintenanceForm and CreateCarsFleetSpotChecksMaintenanceForm which are opened as a dialog. ViewCarsDetailsForm can be opened only once into MDI container but ViewCarMaintenancesForm can be opened per each car into MDI container. It is done by FormsManager presented in third post.
The BaseForm has the icon displayed at the left upper corner and a property Key used to store the key of the form used by FormsManager. All forms derive from it and FormsManager accepts to open only forms assignable from that type.
Each view form has a menu which is not visible but when such form comes active it is automatically added to the main menu of the MDI container. If you download the source code You may be notice that MDI child forms menu is placed at the second position. To configure this one should keep MergeAction and MergeIndex of the MDI container’s menu with default values. But for the MDI child forms one should set MergeAction to Insert and set MergeIndex to 1.
Every menu operation has assigned shortcut key in order to be easy accessible. It is very useful and it is a normal practice when WinFomrs application is developed. It can be done very easy just go to the menu item properties and under Misc category set its ShortcutKeys and ShowShortcutKeys properties the way you preferred.
Below is the look of the application. To have a better look one can add nice icons to the buttons and menus.
And that is the end I didn’t post any code here! Feel free to download and do whatever with it if you found it useful!

