How to: Arrange MDI Child Forms
Often, applications will have menu commands for actions such as Tile, Cascade, and Arrange, which control the layout of the open MDI child forms. You can use the LayoutMdi method with one of the MdiLayout enumeration values to rearrange the child forms in an MDI parent form.
The MdiLayout enumeration values display child forms as cascading, as horizontally or vertically tiled, or as child form icons arranged along the lower portion of the MDI form. These values have the same effect as the Windows commands Cascade windows, Show windows side by side, Show windows stacked, and Show the desktop, respectively.
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 MdiLayout.Cascade enumeration value 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
You can also tile windows and arranging windows as icons by changing the MdiLayout enumeration value used.
If you’re using 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
.NET Desktop feedback