How to: Arrange MDI Child Forms
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 method with the MdiLayout 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.
Protected Sub CascadeWindows_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Me.LayoutMdi(System.Windows.Forms.MdiLayout.Cascade) End Sub
protected void CascadeWindows_Click(object sender, System.EventArgs e){ this.LayoutMdi(System.Windows.Forms.MdiLayout.Cascade); }
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#) Place the following code in the form's constructor to register the event handler.
this.button1.Click += new System.EventHandler(this.button1_Click);
See Also
Tasks
How to: Create MDI Parent Forms
How to: Create MDI Child Forms
How to: Determine the Active MDI Child
How to: Send Data to the Active MDI Child