Form.IsMdiContainer Form.IsMdiContainer Form.IsMdiContainer Form.IsMdiContainer Property

Definición

Obtiene o establece un valor que indica si el formulario es un contenedor para formularios MDI (interfaz de múltiples documentos) secundarios.Gets or sets a value indicating whether the form is a container for multiple-document interface (MDI) child forms.

public:
 property bool IsMdiContainer { bool get(); void set(bool value); };
public bool IsMdiContainer { get; set; }
member this.IsMdiContainer : bool with get, set
Public Property IsMdiContainer As Boolean

Valor de propiedad

Es true si el formulario es un contenedor de formularios MDI secundarios; en caso contrario, es false.true if the form is a container for MDI child forms; otherwise, false. De manera predeterminada, es false.The default is false.

Ejemplos

En el siguiente ejemplo se muestra IsMdiContainer el uso de la propiedad, BackColor así como el cambio de la propiedad de un formulario MDI.The following example demonstrates using the IsMdiContainer property as well as changing the BackColor property of an MDI Form. Para ejecutar este ejemplo, pegue el código siguiente en un nuevo formulario.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;
		}
	}

}

' Create a new form.
Dim mdiChildForm As New Form

Private Sub Form1_Load(ByVal sender As Object, _
    ByVal e As System.EventArgs) Handles MyBase.Load

    ' Set the IsMdiContainer property to true.
    IsMdiContainer = True

    ' Set the child form's MdiParent property to 
    ' the current form.
    mdiChildForm.MdiParent = Me

    'Call the method that changes the background color.
    SetBackGroundColorOfMDIForm()
End Sub

Private Sub SetBackGroundColorOfMDIForm()
    Dim ctl As Control

    ' Loop through controls,  
    ' looking for controls of MdiClient type. 
    For Each ctl In Me.Controls
        If TypeOf (ctl) Is MdiClient Then

            ' If the control is the correct type,
            ' change the color.
            ctl.BackColor = System.Drawing.Color.PaleGreen
        End If
    Next

End Sub

Comentarios

Esta propiedad cambia la presentación y el comportamiento del formulario a un formulario primario MDI.This property changes the display and behavior of the form to an MDI parent form. Cuando esta propiedad está establecida en true, el formulario muestra un área cliente hundida con un borde elevado.When this property is set to true, the form displays a sunken client area with a raised border. Todos los formularios MDI secundarios asignados al formulario primario se muestran dentro de su área de cliente.All MDI child forms assigned to the parent form are displayed within its client area.

Cuando se cierra un formulario primario MDI, se Closing generan los eventos de todos los formularios MDI secundarios antes de que se genere Closing el evento del formulario MDI principal.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. Además, los Closed eventos de todos los formularios MDI secundarios se generan antes de Closed que se produzca el evento del formulario primario MDI.In addition, the Closed events of all MDI child forms are raised before the Closed event of the MDI parent form is raised.

Nota

Si hay dos MenuStrip controles en un formulario MDI secundario, al establecer IsMdiContainer en true para el formulario primario se combina el contenido de solo uno de los MenuStrip controles.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. Utilice Merge para combinar el contenido de los controles MenuStrip secundarios adicionales en el formulario primario MDI.Use Merge to merge the contents of additional child MenuStrip controls on the MDI parent form.

Se aplica a

Consulte también: