Export (0) Print
Expand All

Form.IsMdiContainer Property

Gets or sets a value indicating whether the form is a container for multiple-document interface (MDI) child forms.

Namespace:  System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

public bool IsMdiContainer { get; set; }

Property Value

Type: System.Boolean
true if the form is a container for MDI child forms; otherwise, false. The default is false.

This property changes the display and behavior of the form to an MDI parent form. When this property is set to true, the form displays a sunken client area with a raised border. All MDI child forms assigned to the parent form are displayed within its client area.

When an MDI parent form is closed, the Closing events of all MDI child forms are raised before the MDI parent form's Closing event is raised. In addition, the Closed events of all MDI child forms are raised before the Closed event of the MDI parent form is raised.

NoteNote

If there are two MenuStrip controls on an MDI child form, setting IsMdiContainer to true for the parent form merges the contents of only one of the MenuStrip controls. Use Merge to merge the contents of additional child MenuStrip controls on the MDI parent form.

The following code example demonstrates using the IsMdiContainer property as well as changing the BackColor property of an MDI Form. To run this example, paste the following code in a new form.


	// Create a new form.
	Form mdiChildForm = new Form();

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

		// Set the IsMdiContainer property to true.
		IsMdiContainer = true;

		// Set the child form's MdiParent property to  
		// the current form.
		mdiChildForm.MdiParent = this;

		// Call the method that changes the background color.
		SetBackGroundColorOfMDIForm();
	}

	private void SetBackGroundColorOfMDIForm()
	{
		foreach ( Control ctl in this.Controls )
		{
			if ((ctl) is MdiClient)

				// If the control is the correct type, 
				// change the color.
			{
				ctl.BackColor = System.Drawing.Color.PaleGreen;
			}
		}

	}
To run this example paste the following code in a new form.

.NET Framework

Supported in: 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft