Form.IsMdiContainer : Form « System.Windows.Forms « C# / C Sharp by API






Form.IsMdiContainer

   

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

  public class Form2 : Form
  {
    private System.Windows.Forms.Button Button3;
    private System.Windows.Forms.Button Button2;
    private System.Windows.Forms.Button Button1;
      
      
    public Form2()
    {
      InitializeComponent();
    }
    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(120, 56);
      this.Button3.Name = "Button3";
      this.Button3.Size = new System.Drawing.Size(88, 32);
      this.Button3.TabIndex = 8;
      this.Button3.Text = "Become Child of Parent2";
      this.Button3.Click += new System.EventHandler(this.Button3_Click);
      // 
      // Button2
      // 
      this.Button2.Location = new System.Drawing.Point(12, 56);
      this.Button2.Name = "Button2";
      this.Button2.Size = new System.Drawing.Size(88, 32);
      this.Button2.TabIndex = 7;
      this.Button2.Text = "Become Child of Parent1";
      this.Button2.Click += new System.EventHandler(this.Button2_Click);
      // 
      // Button1
      // 
      this.Button1.Location = new System.Drawing.Point(12, 12);
      this.Button1.Name = "Button1";
      this.Button1.Size = new System.Drawing.Size(88, 32);
      this.Button1.TabIndex = 6;
      this.Button1.Text = "Become Parent";
      this.Button1.Click += new System.EventHandler(this.Button1_Click);
      // 
      // Form2
      // 
      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
      this.ClientSize = new System.Drawing.Size(292, 154);
      this.Controls.Add(this.Button3);
      this.Controls.Add(this.Button2);
      this.Controls.Add(this.Button1);
      this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
      this.Name = "Form2";
      this.Text = "Form2";
      this.ResumeLayout(false);

    }

    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 = Program.Main2;
      this.Show();
    }

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

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

    private void Form1_FormClosed(object sender, FormClosedEventArgs e)
    {
      Application.Exit();
    }
    private void InitializeComponent()
    {
      this.SuspendLayout();
      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
      this.ClientSize = new System.Drawing.Size(422, 351);
      this.IsMdiContainer = true;
      this.Name = "Form1";
      this.Text = "Form1";
      this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.Form1_FormClosed);
      this.ResumeLayout(false);

    }
  }

  static class Program
  {
    public static Form1 Main1 = new Form1();
    public static Form1 Main2 = new Form1();
    public static Form2 Child = new Form2();

    [STAThread]
    public static void Main()
    {
      Application.EnableVisualStyles();
      Main1.Text = "Parent 2";
      Main2.Text = "Parent 1";
      Main1.Show();
      Main2.Show();

      Child.MdiParent = Main2;
      Child.Show();

      System.Windows.Forms.Application.Run();
    }
  }

       

   
    
    
  








Related examples in the same category

1.new Form()
2.extends Form
3.Form.AcceptButton
4.Form.ActiveForm.Location
5.Form.Activated
6.Form.AddOwnedForm
7.Form.AutoScaleBaseSize
8.Form.AutoScroll
9.Form.AutoScrollMinSize
10.Form.BackColor
11.Form.CancelButton
12.Form.CenterToScreen()
13.Form.ClientRectangle
14.Form.ClientSize
15.Form.Closed
16.Form.Closing
17.Form.ContextMenu
18.Form.ControlBox
19.Form.Controls
20.Form.Cursor
21.Form.DesktopBounds
22.Form.DialogResult
23.Form.DisplayRectangle
24.Form.Dispose
25.Form.FormBorderStyle
26.Form.ForeColor
27.Form.GotFocus
28.Form.Height
29.Form.Hide()
30.Form.Invalidate
31.Form.KeyPress
32.Form.KeyPreview
33.Form.KeyUp
34.Form.Load
35.Form.Location
36.Form.MaximizeBox
37.Form.MaximumSize
38.Form.MdiParent
39.Form.MenuComplete
40.Form.Menu
41.Form.MinimizeBox
42.Form.MinimumSize
43.Form.MouseDown
44.Form.MouseLeave(All other events)
45.Form.MouseUp
46.Form.OnDragDrop
47.Form.OnDragOver
48.Form.OnInputLanguageChanged
49.Form.OnKeyDown
50.Form.OnKeyPress
51.Form.OnMouseEnter
52.Form.OnMouseHover
53.Form.OnMouseLeave
54.Form.OnMouseMove
55.Form.OnMouseWheel
56.Form.OnPaint(PaintEventArgs e)
57.Form.OnResize
58.Form.Opacity
59.Form.Paint
60.Form.Region
61.Form.Resize
62.Form.ResizeRedraw
63.Form.SetStyle
64.Form.ShowInTaskbar
65.Form.Size
66.Form.Show
67.Form.StartPosition
68.Form.SuspendLayout
69.Form.Text
70.Form.Top
71.Form.TransparencyKey
72.Form.Visible
73.Form.Width
74.Form.WindowState