MDI children form background : MDI « GUI Windows Forms « C# / CSharp Tutorial

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. GUI Windows Forms
23. 2D
24. Design Patterns
25. Windows
26. XML
27. ADO.Net
28. Network
29. Directory Services
30. Security
31. unsafe
Microsoft Office Word 2007 Tutorial
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
C# / C Sharp
ASP.Net
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
PHP
Python
SQL Server / T-SQL
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
C# / CSharp Tutorial » GUI Windows Forms » MDI 
22. 6. 1. MDI children form background
MDI children form background
 

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

public partial class ChildForm : Form
{
    public ChildForm()
    {
        InitializeComponent();
    }

    private void settoRedToolStripMenuItem_Click(object sender, EventArgs e)
    {
        this.BackColor = Color.Red;
    }

    private void settoBlueToolStripMenuItem_Click(object sender, EventArgs e)
    {
        this.BackColor = Color.Blue;
    }

    private void settoGreenToolStripMenuItem_Click(object sender, EventArgs e)
    {
        this.BackColor = Color.Green;
    }

    public void Save()
    {
        MessageBox.Show("I have saved my data!");
    }
}
partial class ChildForm
{
    private void InitializeComponent()
    {
        this.menuStrip1 = new System.Windows.Forms.MenuStrip();
        this.specialToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
        this.settoRedToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
        this.settoBlueToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
        this.settoGreenToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
        this.menuStrip1.SuspendLayout();
        this.SuspendLayout();
        // 
        // menuStrip1
        // 
        this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
        this.specialToolStripMenuItem});
        this.menuStrip1.Location = new System.Drawing.Point(00);
        this.menuStrip1.Name = "menuStrip1";
        this.menuStrip1.Size = new System.Drawing.Size(53424);
        this.menuStrip1.TabIndex = 0;
        this.menuStrip1.Text = "menuStrip1";
        // 
        // specialToolStripMenuItem
        // 
        this.specialToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
        this.settoRedToolStripMenuItem,
        this.settoBlueToolStripMenuItem,
        this.settoGreenToolStripMenuItem});
        this.specialToolStripMenuItem.Name = "specialToolStripMenuItem";
        this.specialToolStripMenuItem.Text = "&Special";
        // 
        // settoRedToolStripMenuItem
        // 
        this.settoRedToolStripMenuItem.ImageTransparentColor = System.Drawing.Color.Magenta;
        this.settoRedToolStripMenuItem.Name = "settoRedToolStripMenuItem";
        this.settoRedToolStripMenuItem.Text = "Set to Red";
        this.settoRedToolStripMenuItem.Click += new System.EventHandler(this.settoRedToolStripMenuItem_Click);
        // 
        // settoBlueToolStripMenuItem
        // 
        this.settoBlueToolStripMenuItem.ImageTransparentColor = System.Drawing.Color.Magenta;
        this.settoBlueToolStripMenuItem.Name = "settoBlueToolStripMenuItem";
        this.settoBlueToolStripMenuItem.Text = "Set to Blue";
        this.settoBlueToolStripMenuItem.Click += new System.EventHandler(this.settoBlueToolStripMenuItem_Click);
        // 
        // settoGreenToolStripMenuItem
        // 
        this.settoGreenToolStripMenuItem.ImageTransparentColor = System.Drawing.Color.Magenta;
        this.settoGreenToolStripMenuItem.Name = "settoGreenToolStripMenuItem";
        this.settoGreenToolStripMenuItem.Text = "Set to Green";
        this.settoGreenToolStripMenuItem.Click += new System.EventHandler(this.settoGreenToolStripMenuItem_Click);
        // 
        // ChildForm
        // 
        this.AutoScaleDimensions = new System.Drawing.SizeF(6F13F);
        this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
        this.ClientSize = new System.Drawing.Size(534541);
        this.Controls.Add(this.menuStrip1);
        this.MainMenuStrip = this.menuStrip1;
        this.Name = "ChildForm";
        this.Text = "ChildForm";
        this.menuStrip1.ResumeLayout(false);
        this.ResumeLayout(false);
        this.PerformLayout();

    }

    private System.Windows.Forms.MenuStrip menuStrip1;
    private System.Windows.Forms.ToolStripMenuItem specialToolStripMenuItem;
    private System.Windows.Forms.ToolStripMenuItem settoRedToolStripMenuItem;
    private System.Windows.Forms.ToolStripMenuItem settoBlueToolStripMenuItem;
    private System.Windows.Forms.ToolStripMenuItem settoGreenToolStripMenuItem;
}

public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
    }

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



    private void saveToolStripMenuItem_Click(object sender, EventArgs e)
    {
        ChildForm formToSave = (ChildForm)this.ActiveMdiChild;
        formToSave.Save();
    }

    private void fileToolStripMenuItem_DropDownOpening(object sender, EventArgs e)
    {
        if (this.MdiChildren.Length == 0)
            saveToolStripMenuItem.Enabled = false;
        else
            saveToolStripMenuItem.Enabled = true;
    }
}

partial class Form1
{
    private void InitializeComponent()
    {
        this.menuStrip1 = new System.Windows.Forms.MenuStrip();
        this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
        this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
        this.newToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
        this.saveToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
        this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
        this.menuStrip1.SuspendLayout();
        this.SuspendLayout();
        // 
        // menuStrip1
        // 
        this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
        this.fileToolStripMenuItem});
        this.menuStrip1.Location = new System.Drawing.Point(00);
        this.menuStrip1.Name = "menuStrip1";
        this.menuStrip1.Size = new System.Drawing.Size(57624);
        this.menuStrip1.TabIndex = 0;
        this.menuStrip1.Text = "menuStrip1";
        // 
        // fileToolStripMenuItem
        // 
        this.fileToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
        this.newToolStripMenuItem,
        this.saveToolStripMenuItem,
        this.toolStripSeparator1,
        this.exitToolStripMenuItem});
        this.fileToolStripMenuItem.Name = "fileToolStripMenuItem";
        this.fileToolStripMenuItem.Text = "&File";
        this.fileToolStripMenuItem.DropDownOpening += new System.EventHandler(this.fileToolStripMenuItem_DropDownOpening);
        // 
        // toolStripSeparator1
        // 
        this.toolStripSeparator1.Name = "toolStripSeparator1";
        // 
        // newToolStripMenuItem
        // 
        this.newToolStripMenuItem.ImageTransparentColor = System.Drawing.Color.Magenta;
        this.newToolStripMenuItem.Name = "newToolStripMenuItem";
        this.newToolStripMenuItem.Text = "&New";
        this.newToolStripMenuItem.Click += new System.EventHandler(this.newToolStripMenuItem_Click);
        // 
        // saveToolStripMenuItem
        // 
        this.saveToolStripMenuItem.ImageTransparentColor = System.Drawing.Color.Magenta;
        this.saveToolStripMenuItem.Name = "saveToolStripMenuItem";
        this.saveToolStripMenuItem.Text = "&Save";
        this.saveToolStripMenuItem.Click += new System.EventHandler(this.saveToolStripMenuItem_Click);
        // 
        // exitToolStripMenuItem
        // 
        this.exitToolStripMenuItem.ImageTransparentColor = System.Drawing.Color.Magenta;
        this.exitToolStripMenuItem.Name = "exitToolStripMenuItem";
        this.exitToolStripMenuItem.Text = "E&xit";
        // 
        // Form1
        // 
        this.AutoScaleDimensions = new System.Drawing.SizeF(6F13F);
        this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
        this.ClientSize = new System.Drawing.Size(576438);
        this.Controls.Add(this.menuStrip1);
        this.IsMdiContainer = true;
        this.MainMenuStrip = this.menuStrip1;
        this.Name = "Form1";
        this.Text = "Form1";
        this.menuStrip1.ResumeLayout(false);
        this.ResumeLayout(false);
        this.PerformLayout();

    }

    private System.Windows.Forms.MenuStrip menuStrip1;
    private System.Windows.Forms.ToolStripMenuItem fileToolStripMenuItem;
    private System.Windows.Forms.ToolStripMenuItem saveToolStripMenuItem;
    private System.Windows.Forms.ToolStripSeparator toolStripSeparator1;
    private System.Windows.Forms.ToolStripMenuItem exitToolStripMenuItem;
    private System.Windows.Forms.ToolStripMenuItem newToolStripMenuItem;
}

public class ChildFormBackGround
{
    [STAThread]
    static void Main()
    {
        Application.EnableVisualStyles();
        Application.Run(new Form1());
    }
}

        
22. 6. MDI
22. 6. 1. MDI children form backgroundMDI children form background
22. 6. 2. Arrange Child formArrange Child form
w___ww.j_av___a__2__s__.__c_o__m___ | Contact Us
Copyright 2003 - 08 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.