- using System;
- using System.Drawing;
- using System.Collections;
- using System.ComponentModel;
- using System.Windows.Forms;
- using System.Data;
- namespace SimpleMDIApp
- {
- /// <summary>
- /// Summary description for Form1.
- /// </summary>
- public class ParentForm : System.Windows.Forms.Form
- {
- private System.Windows.Forms.MainMenu menuMain;
- private System.Windows.Forms.MenuItem menuFile;
- private System.Windows.Forms.MenuItem menuFileNew;
- private System.Windows.Forms.MenuItem menuFileExit;
- private System.Windows.Forms.MenuItem menuWin;
- private System.Windows.Forms.MenuItem menuItem1;
- /// <summary>
- /// Required designer variable.
- /// </summary>
- private System.ComponentModel.Container components = null;
- public ParentForm()
- {
- //
- // 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 Dispose( bool disposing )
- {
- if( disposing )
- {
- if (components != null)
- {
- components.Dispose();
- }
- }
- base.Dispose( disposing );
- }
- #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.menuMain = new System.Windows.Forms.MainMenu();
- this.menuFile = new System.Windows.Forms.MenuItem();
- this.menuFileNew = new System.Windows.Forms.MenuItem();
- this.menuFileExit = new System.Windows.Forms.MenuItem();
- this.menuWin = new System.Windows.Forms.MenuItem();
- this.menuItem1 = new System.Windows.Forms.MenuItem();
- //
- // menuMain
- //
- this.menuMain.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
- this.menuFile,
- this.menuWin});
- //
- // menuFile
- //
- this.menuFile.Index = 0;
- this.menuFile.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
- this.menuFileNew,
- this.menuItem1,
- this.menuFileExit});
- this.menuFile.Text = "File";
- //
- // menuFileNew
- //
- this.menuFileNew.Index = 0;
- this.menuFileNew.Text = "New";
- this.menuFileNew.Click += new System.EventHandler(this.mnuFileNew_Click);
- //
- // menuFileExit
- //
- this.menuFileExit.Index = 2;
- this.menuFileExit.Text = "Exit";
- //
- // menuWin
- //
- this.menuWin.Index = 1;
- this.menuWin.MdiList = true;
- this.menuWin.MergeOrder = 3;
- this.menuWin.Text = "Window";
- //
- // menuItem1
- //
- this.menuItem1.Index = 1;
- this.menuItem1.Text = "Another New";
- this.menuItem1.Click += new System.EventHandler(this.menuItem1_Click);
- //
- // ParentForm
- //
- this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
- this.ClientSize = new System.Drawing.Size(552, 385);
- this.IsMdiContainer = true;
- this.Menu = this.menuMain;
- this.Name = "ParentForm";
- this.Text = "Form1";
- }
- #endregion
- private void mnuFileNew_Click(object sender, System.EventArgs e)
- {
- ChildForm frm = new ChildForm();
- frm.Name = string.Concat("MDIChildForm", this.MdiChildren.Length.ToString());
- frm.Text = frm.Name;
- frm.MdiParent = this;
- frm.Show();
- }
- private void menuItem1_Click(object sender, System.EventArgs e)
- {
- AnotherChildForm frm = new AnotherChildForm();
- frm.Name = string.Concat("AnotherMDIChildForm", this.MdiChildren.Length.ToString());
- frm.Text = frm.Name;
- frm.MdiParent = this;
- frm.Show();
- }
- }
- }