Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Use the multiple-document interface (MDI) to create applications that can open several documents at the same time and copy and paste content from one document to the other.
This procedure shows you how to create a list of all the active child forms on the parent's Window menu.
To create an MDI Window list on a MenuStrip
Create a form and set its IsMdiContainer property to
true.Add a MenuStrip to the form.
Add two top-level menu items to the MenuStrip and set their Text properties to
&Fileand&Window.Add two submenu items to the
&Filemenu item and set their Text properties to&Openand&New.Set the MdiWindowListItem property of the MenuStrip to the
&WindowToolStripMenuItem.Add a form to the project and add the control you want to it, such as another MenuStrip.
Create an event handler for the Click event of the
&NewToolStripMenuItem.Within the event handler, insert code similar to the following to create and display new instances of
Form2as MDI children ofForm1.Private Sub openToolStripMenuItem_Click(ByVal sender As _ System.Object, ByVal e As System.EventArgs) Handles _ openToolStripMenuItem.Click Dim NewMDIChild As New Form2() 'Set the parent form of the child window. NewMDIChild.MdiParent = Me 'Display the new form. NewMDIChild.Show() End Subprivate void newToolStripMenuItem_Click(object sender, EventArgs e) { Form2 newMDIChild = new Form2(); // Set the parent form of the child window. newMDIChild.MdiParent = this; // Display the new form. newMDIChild.Show(); }
Compiling the Code
This example requires:
Two Form controls named
Form1andForm2.A MenuStrip control on
Form1namedmenuStrip1, and a MenuStrip control onForm2namedmenuStrip2.References to the System and System.Windows.Forms assemblies.
See also
.NET Desktop feedback