Events
Mar 17, 11 PM - Mar 21, 11 PM
Join the meetup series to build scalable AI solutions based on real-world use cases with fellow developers and experts.
Register nowThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
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.
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 &File
and &Window
.
Add two submenu items to the &File
menu item and set their Text properties to &Open
and &New
.
Set the MdiWindowListItem property of the MenuStrip to the &Window
ToolStripMenuItem.
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 &New
ToolStripMenuItem.
Within the event handler, insert code similar to the following to create and display new instances of Form2
as MDI children of Form1
.
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 Sub
private 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();
}
This example requires:
Two Form controls named Form1
and Form2
.
A MenuStrip control on Form1
named menuStrip1
, and a MenuStrip control on Form2
named menuStrip2
.
References to the System and System.Windows.Forms assemblies.
.NET Desktop feedback feedback
.NET Desktop feedback is an open source project. Select a link to provide feedback:
Events
Mar 17, 11 PM - Mar 21, 11 PM
Join the meetup series to build scalable AI solutions based on real-world use cases with fellow developers and experts.
Register nowTraining
Module
Create multi-page .NET MAUI apps with tab and flyout navigation - Training
Use .NET Multi-platform App UI (MAUI) shell to create multi-page applications with tabs and flyout navigation.
Documentation
Learn how to use ToolStripPanel controls with an MDI form that also supports menu merging with child menus.
Walkthrough: Providing Standard Menu Items to a Form - Windows Forms .NET Framework
Learn how to use a MenuStrip control to create a standard menu for forms which also responds when a user selects a menu item.
How to: Append a MenuStrip to an MDI Parent Window - Windows Forms .NET Framework
Learn how to append a MenuStrip to an MDI parent window using IsMdiContainer, AllowMerge, MergeAction, and MergeIndex properties.