Arrange Child form : MDI « GUI Windows Forms « C# / CSharp Tutorial

Home
C# / CSharp Tutorial
1.Language Basics
2.Data Type
3.Operator
4.Statement
5.String
6.struct
7.Class
8.Operator Overload
9.delegate
10.Attribute
11.Data Structure
12.Assembly
13.Date Time
14.Development
15.File Directory Stream
16.Preprocessing Directives
17.Regular Expression
18.Generic
19.Reflection
20.Thread
21.I18N Internationalization
22.LINQ
23.GUI Windows Forms
24.Windows Presentation Foundation
25.Windows Communication Foundation
26.Workflow
27.2D
28.Design Patterns
29.Windows
30.XML
31.XML LINQ
32.ADO.Net
33.Network
34.Directory Services
35.Security
36.unsafe
C# / C Sharp
C# / C Sharp by API
C# / CSharp Open Source
C# / CSharp Tutorial » GUI Windows Forms » MDI 
23.6.4.Arrange Child form
Arrange Child form
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

public class MDIFormArrange : System.Windows.Forms.Form
{
  private System.Windows.Forms.MainMenu mainMenu1;
  private System.Windows.Forms.MenuItem mnuFile;
  private System.Windows.Forms.MenuItem mnuFileExit;
  private System.Windows.Forms.MenuItem mnuWindow;
  private System.Windows.Forms.MenuItem mnuArrange;
  private System.Windows.Forms.MenuItem mnuArrangeCascade;
  private System.Windows.Forms.MenuItem mnuArrangeVert;
  private System.Windows.Forms.MenuItem mnuArrangeHorizontal;
  private System.Windows.Forms.MenuItem mnuFileNew;

  private System.ComponentModel.Container components = null;

  public MDIFormArrange()
  {
    InitializeComponent();
  }

  protected override void Disposebool disposing )
  {
    ifdisposing )
    {
      if (components != null
      {
        components.Dispose();
      }
    }
    base.Disposedisposing );
  }

  private void InitializeComponent()
  {
    this.mainMenu1 = new System.Windows.Forms.MainMenu();
    this.mnuFile = new System.Windows.Forms.MenuItem();
    this.mnuFileNew = new System.Windows.Forms.MenuItem();
    this.mnuFileExit = new System.Windows.Forms.MenuItem();
    this.mnuWindow = new System.Windows.Forms.MenuItem();
    this.mnuArrange = new System.Windows.Forms.MenuItem();
    this.mnuArrangeCascade = new System.Windows.Forms.MenuItem();
    this.mnuArrangeVert = new System.Windows.Forms.MenuItem();
    this.mnuArrangeHorizontal = new System.Windows.Forms.MenuItem();
    // 
    this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
                                          this.mnuFile,
                                          this.mnuWindow,
                                          this.mnuArrange});
    // 
    this.mnuFile.Index = 0;
    this.mnuFile.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
                                        this.mnuFileNew,
                                        this.mnuFileExit});
    this.mnuFile.Text = "&File";
    // 
    this.mnuFileNew.Index = 0;
    this.mnuFileNew.Text = "&New";
    this.mnuFileNew.Click += new System.EventHandler(this.mnuFileNew_Click);
    // 
    this.mnuFileExit.Index = 1;
    this.mnuFileExit.Text = "E&xit";
    this.mnuFileExit.Click += new System.EventHandler(this.mnuFileExit_Click);
    // 
    this.mnuWindow.Index = 1;
    this.mnuWindow.MdiList = true;
    this.mnuWindow.Text = "&Window";
    // 
    this.mnuArrange.Index = 2;
    this.mnuArrange.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
                                           this.mnuArrangeCascade,
                                           this.mnuArrangeVert,
                                           this.mnuArrangeHorizontal});
    this.mnuArrange.Text = "&Arrange Window";
    // 
    this.mnuArrangeCascade.Index = 0;
    this.mnuArrangeCascade.Text = "&Cascade";
    this.mnuArrangeCascade.Click += new System.EventHandler(this.mnuArrangeCascade_Click);
    // 
    this.mnuArrangeVert.Index = 1;
    this.mnuArrangeVert.Text = "&Vertical";
    this.mnuArrangeVert.Click += new System.EventHandler(this.mnuArrangeVert_Click);
    // 
    this.mnuArrangeHorizontal.Index = 2;
    this.mnuArrangeHorizontal.Text = "&Horizontal";
    this.mnuArrangeHorizontal.Click += new System.EventHandler(this.mnuArrangeHorizontal_Click);
    // 
    this.AutoScaleBaseSize = new System.Drawing.Size(513);
    this.ClientSize = new System.Drawing.Size(292269);
    this.IsMdiContainer = true;
    this.Menu = this.mainMenu1;
    this.Name = "MDIFormArrange";
    this.Text = "The MDI Application";

  }

  [STAThread]
  static void Main() 
  {
    Application.Run(new MDIFormArrange());
  }

  private void mnuFileExit_Click(object sender, System.EventArgs e)
  
      this.Close()
  }

  private void mnuArrangeCascade_Click(object sender, System.EventArgs e)
  
      LayoutMdi(MdiLayout.Cascade)
  }

  private void mnuArrangeVert_Click(object sender, System.EventArgs e)
  
      LayoutMdi(MdiLayout.TileVertical)
  }

  private void mnuArrangeHorizontal_Click(object sender, System.EventArgs e)
  
      LayoutMdi(MdiLayout.TileHorizontal)
  }

  private void mnuFileNew_Click(object sender, System.EventArgs e)
  {
    MDIChildForm newChild = new MDIChildForm();

    newChild.MdiParent = this;

    newChild.Show();    
  }
}
public class MDIChildForm : System.Windows.Forms.Form
{
  private System.ComponentModel.Container components = null;

  public MDIChildForm()
  {
    InitializeComponent();

  }

  protected override void Disposebool disposing )
  {
    ifdisposing )
    {
      if(components != null)
      {
        components.Dispose();
      }
    }
    base.Disposedisposing );
  }

  private void InitializeComponent()
  {
    this.AutoScaleBaseSize = new System.Drawing.Size(513);
    this.ClientSize = new System.Drawing.Size(292269);
  }
}
23.6.MDI
23.6.1.Is a form Mdi Container
23.6.2.Set MdiParent
23.6.3.MDI children form backgroundMDI children form background
23.6.4.Arrange Child formArrange Child form
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.