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.
Output:
MDI FORMS
Here in this, we have three forms out of which 1 is set to be MDI true and the other two forms are the child forms of the MDI Form and are opened with the help of menu provided.
Menus: For a computer application, a menu is a list of actions that can be performed on that program. To be aware of these actions, the list must be presented to the user upon request. For a graphical application, a menu is presented as a list of words and, using a mouse or a keyboard, the user can select the desired item from the menu.
Common Properties of Context Menu Strip:
Properties Description Name To change the name of menu strip AutoSize To change the size of menu strip BackColor To change the background color. Enable To set the enabling or disenabling. Font To change the font style of text Items To add the items to menu strip.
Common Properties of Menu Items:
Properties Description Name To change the name of menu item BackColor To change the background color. Checked To check mark in front of Menu Items Enable To set the enabling or disenabling. Font To change the font style of text ForeColor To change the text color of Menu Items ShortcutKeys To assign shortcut to the Menu Items ShowShortcutKeys To indicate wheather the shortcut key or not. Text To set the menu item text. TextDirection To set the direction of the text. Visible To set the visibility of menu item.
Application to explain the Context Menu Strip:
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 cutToolStripMenuItem_Click(object sender, EventArgs e)
{
richTextBox1.Cut();
}
private void copyToolStripMenuItem_Click(object sender, EventArgs e)
{
richTextBox1.Copy();
}
private void pasteToolStripMenuItem_Click(object sender, EventArgs e)
{
richTextBox1.Paste();
}
}
}
Output:

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