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: