Is a form Mdi Container : 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.1.Is a form Mdi Container
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

public class ChildPrototypeForm : Form {
    public ChildPrototypeForm() {
        InitializeComponent();
    }

    private void ChildPrototypeForm_Click(object sender, EventArgs e) {
        int r, g, b;
        Random ran = new Random();
        r = ran.Next(0255);
        g = ran.Next(0255);
        b = ran.Next(0255);

        Color currColor = Color.FromArgb(r, g, b);
        this.BackColor = currColor;
        this.Text = currColor.ToString();
    }
    private void InitializeComponent() {
        this.Click += new System.EventHandler(this.ChildPrototypeForm_Click);
    }
}

public class MainWindow : Form {
    public MainWindow() {
         InitializeComponent();
    }
    private void cascadeToolStripMenuItem_Click(object sender, EventArgs e) { LayoutMdi(MdiLayout.Cascade)}

    private void verticalToolStripMenuItem_Click(object sender, EventArgs e) { LayoutMdi(MdiLayout.TileVertical)}

    private void horizontalToolStripMenuItem_Click(object sender, EventArgs e) { LayoutMdi(MdiLayout.TileHorizontal)}

    private void exitToolStripMenuItem_Click(object sender, EventArgs e) { Application.Exit()}

    private void newToolStripMenuItem_Click(object sender, EventArgs e) {
        ChildPrototypeForm newChild = new ChildPrototypeForm();
        newChild.MdiParent = this;
        newChild.Show();
    }

    private void InitializeComponent() {
        this.menuStrip1 = new System.Windows.Forms.MenuStrip();
        this.fileToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
        this.newToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
        this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
        this.windowToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
        this.arrangeWindowsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
        this.cascadeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
        this.verticalToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
        this.horizontalToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
        this.menuStrip1.SuspendLayout();
        this.SuspendLayout();
        // 
        // menuStrip1
        // 
        this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.fileToolStripMenuItem1,
            this.windowToolStripMenuItem,
            this.arrangeWindowsToolStripMenuItem});
        this.menuStrip1.Location = new System.Drawing.Point(00);
        this.menuStrip1.MdiWindowListItem = this.windowToolStripMenuItem;
        this.menuStrip1.Name = "menuStrip1";
        this.menuStrip1.Size = new System.Drawing.Size(44024);
        this.menuStrip1.TabIndex = 2;
        this.menuStrip1.Text = "menuStrip1";
        // 
        // fileToolStripMenuItem1
        // 
        this.fileToolStripMenuItem1.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.newToolStripMenuItem,
            this.exitToolStripMenuItem});
        this.fileToolStripMenuItem1.Name = "fileToolStripMenuItem1";
        this.fileToolStripMenuItem1.Text = "&File";
        // 
        // newToolStripMenuItem
        // 
        this.newToolStripMenuItem.Name = "newToolStripMenuItem";
        this.newToolStripMenuItem.Text = "&New";
        this.newToolStripMenuItem.Click += new System.EventHandler(this.newToolStripMenuItem_Click);
        // 
        // exitToolStripMenuItem
        // 
        this.exitToolStripMenuItem.Name = "exitToolStripMenuItem";
        this.exitToolStripMenuItem.Text = "E&xit";
        this.exitToolStripMenuItem.Click += new System.EventHandler(this.exitToolStripMenuItem_Click);
        // 
        // windowToolStripMenuItem
        // 
        this.windowToolStripMenuItem.Name = "windowToolStripMenuItem";
        this.windowToolStripMenuItem.Text = "&Window";
        // 
        // arrangeWindowsToolStripMenuItem
        // 
        this.arrangeWindowsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.cascadeToolStripMenuItem,
            this.verticalToolStripMenuItem,
            this.horizontalToolStripMenuItem});
        this.arrangeWindowsToolStripMenuItem.Name = "arrangeWindowsToolStripMenuItem";
        this.arrangeWindowsToolStripMenuItem.Text = "&Arrange Windows";
        // 
        // cascadeToolStripMenuItem
        // 
        this.cascadeToolStripMenuItem.Name = "cascadeToolStripMenuItem";
        this.cascadeToolStripMenuItem.Text = "&Cascade";
        this.cascadeToolStripMenuItem.Click += new System.EventHandler(this.cascadeToolStripMenuItem_Click);
        // 
        // verticalToolStripMenuItem
        // 
        this.verticalToolStripMenuItem.Name = "verticalToolStripMenuItem";
        this.verticalToolStripMenuItem.Text = "&Vertical";
        this.verticalToolStripMenuItem.Click += new System.EventHandler(this.verticalToolStripMenuItem_Click);
        // 
        // horizontalToolStripMenuItem
        // 
        this.horizontalToolStripMenuItem.Name = "horizontalToolStripMenuItem";
        this.horizontalToolStripMenuItem.Text = "&Horizontal";
        this.horizontalToolStripMenuItem.Click += new System.EventHandler(this.horizontalToolStripMenuItem_Click);
        // 
        // MainWindow
        // 
        this.AutoScaleDimensions = new System.Drawing.SizeF(6F13F);
        this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
        this.ClientSize = new System.Drawing.Size(440238);
        this.Controls.Add(this.menuStrip1);
        this.IsMdiContainer = true;
        this.Name = "MainWindow";
        this.Text = "My Mdi Application";
        this.menuStrip1.ResumeLayout(false);
        this.ResumeLayout(false);
        this.PerformLayout();

    }



    private System.Windows.Forms.MenuStrip menuStrip1;
    private System.Windows.Forms.ToolStripMenuItem fileToolStripMenuItem1;
    private System.Windows.Forms.ToolStripMenuItem newToolStripMenuItem;
    private System.Windows.Forms.ToolStripMenuItem exitToolStripMenuItem;
    private System.Windows.Forms.ToolStripMenuItem windowToolStripMenuItem;
    private System.Windows.Forms.ToolStripMenuItem arrangeWindowsToolStripMenuItem;
    private System.Windows.Forms.ToolStripMenuItem cascadeToolStripMenuItem;
    private System.Windows.Forms.ToolStripMenuItem verticalToolStripMenuItem;
    private System.Windows.Forms.ToolStripMenuItem horizontalToolStripMenuItem;

    [STAThread]
    static void Main() {
        Application.EnableVisualStyles();
        Application.Run(new MainWindow());
    }
}
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.