MDI: Multiple Document Interface.
Windows form provides a great deal of flexibility, allowing us to configure the working environment. It provides us with 2 types of interfaces:
-
Single Document Interface
-
Multiple Document Interface
Single Document Interface: Single document interface applications are made up of a single window. Even there are multiple windows but one can be activated at a time.
For example: Notepad.
In this a user is allowed to create or use only one file at a time. That means in this kind of application we are not supposed to open 2 files simultaneously under 1 single window.
Multiple Document Interface: A multiple document interface is an application which we can view and work with several documents at once. In this case, we can open as many as document as we want. For each new document, a child window is opened.
For example: Microsoft Excel.
Microsoft Excel is an application that allows us to work with multiple files at the same time. Each a new document is opened, a new window opens inside the main window.
Creating MDI applications:
For creating MDI applications there are 2 ways.
In the first method we can just include a new MDI Form. For this, choose the Project menu ïƒ Add Window Form ïƒ Add MDI Parent from Visual Studio.
The other way is to convert the existing form into the MDI form by changing its properties. For converting this form, one needs to change the IsMdiContainer property to true.
How to open a form inside MDI Form:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication3
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void form1ToolStripMenuItem_Click(object sender, EventArgs e)
{
Form2 f1 = new Form2();
f1.MdiParent = this;
f1.Show();
}
private void formToolStripMenuItem_Click(object sender, EventArgs e)
{
Form3 f2 = new Form3();
f2.MdiParent = this;
f2.Show();
}
}
}
Before doing this make sure that you have changed the ISMdiContainer property of Form1 to True otherwise one cannot be able to open the form inside the other.

Nikhil KumarPosted Jan 9, 2010, 9:56 AM
keep posting nice blogs :)