SDI Form (single-document-interface) A normally created form
MDI forms (multiple-document-interface) are used to display multiple documents simultaneously. MDI subforms are created to prevent the user from having to open many Windows in the process of filling up the form.
How to use the MDI form
Identify a side form and set the form’s IsMdiContainer property to true.
Create subforms and set their subforms.
Note: To set the properties of the main form, the new subform must be in the main form’s namespace, here: the main form name (MDi)
using System;
using System.Windows.Forms;
namespace MDi
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private voidNew ToolStripMenuItem_Click (object sender, EventArgs e)
{
Child mychild = new Child();
mychild.MdiParent = this;
mychild.Show();
}
private voidCascading ToolStripMenuItem_Click (object sender, EventArgs e)
{
LayoutMdi(MdiLayout.Cascade);
}
private voidLevel ToolStripMenuItem_Click (object sender, EventArgs e)
{
LayoutMdi(MdiLayout.TileHorizontal);
}
private voidThe vertical ToolStripMenuItem_Click (object sender, EventArgs e)
{
LayoutMdi(MdiLayout.TileVertical);
}
private voidClose the ToolStripMenuItem_Click (objectsender, EventArgs e) { Close(); }}}Copy the code
Effect: