< Day Day Up > |
TechniqueUse the LayoutMdi method and pass a value from the MdiLayout enumerated data type. You can arrange MDI child forms in a cascading fashion, tile them vertically, or tile them horizontally, as shown in Listing 7.4. Listing 7.4 Arranging MDI Childrenprivate void Form1_VisibleChanged(object sender, System.EventArgs e) { this.Visible = true; this.LayoutMdi( MdiLayout.Cascade ); MessageBox.Show( "Cascading MDI Child Windows" ); this.LayoutMdi( MdiLayout.TileVertical ); MessageBox.Show( "Vertically Tiled MDI Child Windows" ); this.LayoutMdi( MdiLayout.TileHorizontal ); MessageBox.Show( "Horizontally Tiled MDI Child Windows" ); } CommentsWhenever an overabundant amount of child windows are active within an MDI application, requiring the user to organize them manually is asking too much. Fortunately, Windows Forms allow you to perform the layout of MDI child windows using the MdiLayout method. The code listing in this recipe simply enumerates through each of the MDI layouts. In most cases, the automatic arrangement of child windows occurs within an event handler for a control within the parent window. Generally, automatic child window layout happens within the event handler for a menu item on the parent form's main menu or a toolbar button on the application's toolbar. |
< Day Day Up > |