This documentation is archived and is not being maintained.

Arranging MDI Child Forms

Visual Studio .NET 2003

Often, applications will have menu commands for actions such as Tile, Cascade, and Arrange, with regard to the open MDI child forms. You can use the LayoutMDI (LayoutMdi in C#) method with the MDILayout (MdiLayout in C#) enumeration to rearrange the child forms in an MDI parent form.

One of the four different MDILayout enumeration values can be used by the LayoutMDI method. The enumeration values will display child forms as cascading, as horizontally or vertically tiled, or as child form icons arranged along the lower portion of the MDI form.

Often, these methods are used as the event handlers called by a menu item's Click event. In this way, a menu item with the text "Cascade Windows" can have the desired effect on the MDI child windows.

To arrange child forms

  • In a method, use the LayoutMdi method to set the MdiLayout enumeration for the MDI parent form. The following example uses the Cascade setting of the MdiLayout enumeration for the child windows of the MDI parent form (Form1). The enumeration is used in code during the event handler for the Click event of the Cascade Windows menu item.
    ' Visual Basic
    Protected Sub CascadeWindows_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
    End Sub
    // C#
    protected void CascadeWindows_Click(object sender, System.EventArgs e){
    Note   In the same way, functionality for tiling windows and arranging windows as icons may be set by changing the MdiLayout enumeration value passed to the LayoutMdi method.
    Visual C# Note   Be sure that the necessary code to enable the event handler is present. In this case, it would be similar to the following:
    this.button1.Click += new System.EventHandler(this.button1_Click);

See Also

Multiple-Document Interface (MDI) Applications | Creating MDI Parent Forms | Creating MDI Child Forms | Determining the Active MDI Child | Sending Data to the Active MDI Child