MDI form : MDI « GUI Windows Form « C# / C Sharp

Home
C# / C Sharp
1.2D Graphics
2.Class Interface
3.Collections Data Structure
4.Components
5.Data Types
6.Database ADO.net
7.Design Patterns
8.Development Class
9.Event
10.File Stream
11.Generics
12.GUI Windows Form
13.Language Basics
14.LINQ
15.Network
16.Office
17.Reflection
18.Regular Expressions
19.Security
20.Services Event
21.Thread
22.Web Services
23.Windows
24.Windows Presentation Foundation
25.XML
26.XML LINQ
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source
C# / C Sharp » GUI Windows Form » MDIScreenshots 
MDI form
MDI form

/*
User Interfaces in C#: Windows Forms and Custom Controls
by Matthew MacDonald

Publisher: Apress
ISBN: 1590590457
*/
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace ImpossibleAPI
{
    
    public class Global
    {
        public static Form1 Main1 = new Form1();
        public static Form1 Main2 = new Form1();
        public static Form2 Child = new Form2();                                
                                                                                
        [STAThread]
        public static void Main() 
        {
            Main1.Text = "Parent 2";
            Main2.Text = "Parent 1";
            Main1.Show();
            Main2.Show();
            
            Child.MdiParent = Main2;
            Child.Show();

            System.Windows.Forms.Application.Run();
        }
        
    }
    /// <summary>
    /// Summary description for Form2.
    /// </summary>
    public class Form2 : System.Windows.Forms.Form
    {
        internal System.Windows.Forms.Button Button3;
        internal System.Windows.Forms.Button Button2;
        internal System.Windows.Forms.Button Button1;
        /// <summary>
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.Container components = null;

        public Form2()
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            //
            // TODO: Add any constructor code after InitializeComponent call
            //
        }

        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        protected override void Disposebool disposing )
        {
            ifdisposing )
            {
                if(components != null)
                {
                    components.Dispose();
                }
            }
            base.Disposedisposing );
        }

        #region Windows Form Designer generated code
        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.Button3 = new System.Windows.Forms.Button();
            this.Button2 = new System.Windows.Forms.Button();
            this.Button1 = new System.Windows.Forms.Button();
            this.SuspendLayout();
            // 
            // Button3
            // 
            this.Button3.Location = new System.Drawing.Point(12460);
            this.Button3.Name = "Button3";
            this.Button3.Size = new System.Drawing.Size(8832);
            this.Button3.TabIndex = 5;
            this.Button3.Text = "Become Child of Parent2";
            this.Button3.Click += new System.EventHandler(this.Button3_Click);
            // 
            // Button2
            // 
            this.Button2.Location = new System.Drawing.Point(1660);
            this.Button2.Name = "Button2";
            this.Button2.Size = new System.Drawing.Size(8832);
            this.Button2.TabIndex = 4;
            this.Button2.Text = "Become Child of Parent1";
            this.Button2.Click += new System.EventHandler(this.Button2_Click);
            // 
            // Button1
            // 
            this.Button1.Location = new System.Drawing.Point(1616);
            this.Button1.Name = "Button1";
            this.Button1.Size = new System.Drawing.Size(8832);
            this.Button1.TabIndex = 3;
            this.Button1.Text = "Become Parent";
            this.Button1.Click += new System.EventHandler(this.Button1_Click);
            // 
            // Form2
            // 
            this.AutoScaleBaseSize = new System.Drawing.Size(514);
            this.ClientSize = new System.Drawing.Size(292150);
            this.Controls.AddRange(new System.Windows.Forms.Control[] {
                                                                          this.Button3,
                                                                          this.Button2,
                                                                          this.Button1});
            this.Font = new System.Drawing.Font("Tahoma"8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
            this.Name = "Form2";
            this.Text = "Form2";
            this.ResumeLayout(false);

        }
        #endregion

        private void Button1_Click(object sender, System.EventArgs e)
        {
            this.Hide();
            this.MdiParent = null;
            this.IsMdiContainer = true;
            this.Show();
        }

        private void Button2_Click(object sender, System.EventArgs e)
        {
            this.Hide();
            this.IsMdiContainer = false;
            this.MdiParent = Global.Main2;
            this.Show();
        }

        private void Button3_Click(object sender, System.EventArgs e)
        {
            this.Hide();
            this.IsMdiContainer = false;
            this.MdiParent = Global.Main1;
            this.Show();
        }
    }

    /// <summary>
    /// Summary description for Form1.
    /// </summary>
    public class Form1 : System.Windows.Forms.Form
    {
        /// <summary>
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.Container components = null;

        public Form1()
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            //
            // TODO: Add any constructor code after InitializeComponent call
            //
        }

        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        protected override void Disposebool disposing )
        {
            ifdisposing )
            {
                if (components != null
                {
                    components.Dispose();
                }
            }
            base.Disposedisposing );
        }

        #region Windows Form Designer generated code
        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            // 
            // Form1
            // 
            this.AutoScaleBaseSize = new System.Drawing.Size(513);
            this.ClientSize = new System.Drawing.Size(464370);
            this.IsMdiContainer = true;
            this.Name = "Form1";
            this.Text = "Form1";
            this.Closing += new System.ComponentModel.CancelEventHandler(this.Form1_Closing);
            this.Load += new System.EventHandler(this.Form1_Load);

        }
        #endregion

        private void Form1_Load(object sender, System.EventArgs e)
        {
        
        }

        private void Form1_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            Application.Exit();
        }

        /// <summary>
        /// The main entry point for the application.
        /// </summary>

    }


}



           
       
Related examples in the same category
1.Set MDI parent windowSet MDI parent window
2.Maximized MDI window at startupMaximized MDI window at startup
3.MDI RelativesMDI Relatives
4.Form OwnershipForm Ownership
5.MDI BasicsMDI Basics
6.MDI and DockMDI and Dock
7.MdiLayout.Cascade MdiLayout.Cascade
8.MdiLayout.TileHorizontal MdiLayout.TileHorizontal
9.MdiLayout.TileVerticalMdiLayout.TileVertical
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.