ComponentOne Menus and Toolbars for WinForms
Creating a Window List for an MDI Form
Menus and Toolbars for WinForms Task-Based Help > Menu Tasks > Creating a Window List for an MDI Form

C1Command has a C1CommandMdiList command type used to create a Window list for an MDI (Multiple Document Interface) form. A Window list is useful for keeping track of the various MDI child windows an application has open.

To create a Window list for an MDI form, complete the following steps:

  1. In the Properties window, set the Form1.IsMDIContainer property to True.
  2. In Solution Explorer, right-click the project and select Add| Add New Item.
  3. From the dialog box, select Windows Form, name the form MdiChild, and then set its Text property to MdiChild.
  4. Add the C1MainMenu component to your MDI parent form, Form1.
  5. In the Properties window, set the Name property for the C1MainMenu to C1MainMenu1.
  6. Create the File menu. Add a C1CommandMenu and a submenu item to the C1MainMenu component using the Link to Command designer.

    Set the following properties:

    Command Name Command Type Command Text
    cmdFile C1CommandMenu &File
    cmdFileNew C1Command &New
  7. Create the Window menu to store the MDI child windows. In the Link to Command designer, add another C1CommandMenu to the C1MainMenu component, then add a submenu of the type C1CommandMdiList to it.

    Set the following properties:

    Command Name Command Type Command Text
    cmdWindow C1CommandMenu &Window
    c1CommandMdiList1 C1CommandMdiList <MDI Windows List>
  8. Create a procedure to display new instances of the MdiChild form as MDI children of Form1. Add the following code to your source file:

    To write code in Visual Basic

    Visual Basic
    Copy Code
    Private Sub createNewMdiChild()
            Dim mc As New MdiChild()
            mc.MdiParent = Me
            mc.Text = String.Format("MDI Child Window {0}", Me.MdiChildren.Length)
            mc.Show()
    End Sub
    

    To write code in C#

    C#
    Copy Code
    private void createNewMdiChild()
        {
             MdiChild mc = new MdiChild();
             mc.MdiParent = this;
             mc.Text = string.Format("MDI Child Window {0}", this.MdiChildren.Length);
             mc.Show();
        }
    
  9. In Design view, double-click the cmdFileNew menu item to create a click event handler to call the createNewMdiChild procedure. Add the following code within the event handler:

    To write code in Visual Basic

    Visual Basic
    Copy Code
    createNewMdiChild()
    

    To write code in C#

    C#
    Copy Code
    CreateNewMdiChild();
    
  10. Press F5 to run the application.
  11. From the File menu, click New to create a new MDI child form.

    The C1CommandMdiList expands to the list of available MDI child windows.

    Note: The Window menu always displays a list of the MDI child forms open within the application with a check mark next to the MDI child that has the focus.
See Also