Web Design that taps into the haromny and vision of your dreams.

Using Multiple Forms in C# Applications with MDI

Adding Multiple Document Interface to your projects

Written By on in C#

225 words, estimated reading time 2 minutes.

Multiple Document Interface (MDI) allows one form to have multiple forms contained within it, like multiple Word documents. It allows a group of windows to be contained and managed within a parent form. Child forms all inherit from a single form class and all contain the same controls.

Windows Forms Applications Series
  1. Basics of C# Windows Forms Applications
  2. Menus, Popups and Toolbars in .Net Forms and C#
  3. Using Common Dialogue Boxes in C#
  4. List Boxes and Tree Views in C#
  5. List Box Data Binding in C# Windows Forms Application
  6. Using Multiple Forms in C# Applications with MDI
  7. Creating Controls for Windows Forms and C#
  8. Saving User Preferences and Settings within your C# Application

Visual Studio does all the hard work for you, all you have to do is create a new Windows Forms application and then from the Add a new item dialogue select MDI Parent, give it a name and click OK. Visual Studio will create all the forms, buttons, toolbars and menus that a basic application will need. Right click on Form1 and click on "Exclude From Project". Next, open program.cs and change the line:

Application.Run(new Form1());


Application.Run(new MDIParent1());

This will change the start-up form of the project to the new MDI form.

You can run the application now and test the features. You can create as many new forms as you like; some dialogue boxes are linked up while others have placeholders. One thing you should notice is the Windows menu. This lists common items such as Cascade and Tile Vertical as well as listing the child forms already opened. Menu items to control the layout (Tile, Cascade, Minimise, Arrange Icons etc...) all interface with the forms LayoutMdi method, passing in an Enum.


You can iterate through all the open documents:

foreach (Form childForm in MdiChildren)

A lot of the functionality has been included in the example project supplied, I'll leave it for you to create your own MDI application.

Multiple Document Interface (MDI)
Multiple Document Interface (MDI)

Last updated on: Friday 23rd June 2017




thank you very much.

Reply to mary


Leave a Reply

Your email address will not be published.

If you find something abusive or that does not comply with our terms or guidelines please flag it as inappropriate.

Copyright © 2001-2018 Tim Trott, all rights reserved. Web Design by Azulia Designs

This web page is licensed for your personal, private, non-commercial use only.

Disclaimer, Privacy & LegalSitemapContact Me