---
title: "How to: Create an MDI Window List with MenuStrip"
ms.date: "03/30/2017"
dev_langs: 
  - "csharp"
  - "vb"
helpviewer_keywords: 
  - "MDI [Windows Forms], creating window lists"
  - "MenuStrip control [Windows Forms], creating window lists"
ms.assetid: 04fb414b-811f-4a83-aab6-b4a24646dec5
---
# How to: Create an MDI Window List with MenuStrip (Windows Forms)
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  
  
1. Create a form and set its <xref:System.Windows.Forms.Form.IsMdiContainer%2A> property to `true`.  
  
2. Add a <xref:System.Windows.Forms.MenuStrip> to the form.  
  
3. Add two top-level menu items to the <xref:System.Windows.Forms.MenuStrip> and set their <xref:System.Windows.Forms.Control.Text%2A> properties to `&File` and `&Window`.  
  
4. Add a submenu item to the `&File` menu item and set its <xref:System.Windows.Forms.ToolStripItem.Text%2A> property to `&Open`.  
  
5. Set the <xref:System.Windows.Forms.MenuStrip.MdiWindowListItem%2A> property of the <xref:System.Windows.Forms.MenuStrip> to the `&Window`<xref:System.Windows.Forms.ToolStripMenuItem>.  
  
6. Add a form to the project and add the control you want to it, such as another <xref:System.Windows.Forms.MenuStrip>.  
  
7. Create an event handler for the <xref:System.Windows.Forms.Control.Click> event of the `&New`<xref:System.Windows.Forms.ToolStripMenuItem>.  
  
8. Within the event handler, insert code similar to the following to create and display new instances of `Form2` as MDI children of `Form1`.  
  
    ```vb  
    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  
    ```  
  
    ```csharp  
    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();  
    }  
    ```  
  
9. Place code like the following in the `&New`<xref:System.Windows.Forms.ToolStripMenuItem> to register the event handler.  
  
    ```vb  
    Private Sub newToolStripMenuItem_Click(sender As Object, e As _  
    EventArgs) Handles newToolStripMenuItem.Click  
    ```  
  
    ```csharp  
    this.newToolStripMenuItem.Click += new System.EventHandler(this.newToolStripMenuItem_Click);  
    ```  
  
## Compiling the Code  
 This example requires:  
  
- Two <xref:System.Windows.Forms.Form> controls named `Form1` and `Form2`.  
  
- A <xref:System.Windows.Forms.MenuStrip> control on `Form1` named `menuStrip1`, and a <xref:System.Windows.Forms.MenuStrip> control on `Form2` named `menuStrip2`.  
  
- References to the <xref:System?displayProperty=nameWithType> and <xref:System.Windows.Forms?displayProperty=nameWithType> assemblies.  
  
## See also

- [How to: Create MDI Parent Forms](../advanced/how-to-create-mdi-parent-forms.md)
- [How to: Create MDI Child Forms](../advanced/how-to-create-mdi-child-forms.md)
- [MenuStrip Control](menustrip-control-windows-forms.md)
