Form.IsMdiContainer (Propiedad)
Obtiene o establece un valor que indica si el formulario es un contenedor para formularios MDI (interfaz de múltiples documentos) secundarios.

Espacio de nombres: System.Windows.Forms
Ensamblado: System.Windows.Forms (en system.windows.forms.dll)

Sintaxis

Visual Basic (Declaración)
Public Property IsMdiContainer As Boolean
Visual Basic (Uso)
Dim instance As Form
Dim value As Boolean

value = instance.IsMdiContainer

instance.IsMdiContainer = value
C#
public bool IsMdiContainer { get; set; }
C++
public:
property bool IsMdiContainer {
    bool get ();
    void set (bool value);
}
J#
/** @property */
public boolean get_IsMdiContainer ()

/** @property */
public void set_IsMdiContainer (boolean value)
JScript
public function get IsMdiContainer () : boolean

public function set IsMdiContainer (value : boolean)
XAML
No aplicable.

Valor de propiedad

Es true si el formulario es un contenedor de formularios MDI secundarios; en caso contrario, es false. El valor predeterminado es false.
Comentarios

Esta propiedad cambia la presentación y el comportamiento de un formulario MDI principal. Cuando esta propiedad se establece en true, el formulario muestra un área de cliente hundida con un borde en relieve. Todos los formularios MDI secundarios asignados al formulario principal se muestran dentro de su área de cliente.

Cuando se cierra un formulario MDI principal, los eventos Closing de todos los formularios MDI secundarios se provocan antes de que se provoque el evento Closing del formulario MDI principal. Además, los eventos Closed de todos los formularios MDI secundarios se provocan antes de que se provoque el evento Closed del formulario MDI principal.

NotaNota:

Si hay dos controles MenuStrip en un formulario MDI secundario, el establecimiento de IsMdiContainer en true para el formulario principal combina el contenido de sólo uno de los controles MenuStrip. Utilice Merge para combinar el contenido de otros controles MenuStrip secundarios en el formulario MDI principal.

Ejemplo

En el siguiente ejemplo de código se muestra cómo usar la propiedad IsMdiContainer y cómo cambiar la propiedad BackColor de un formulario MDI. Para ejecutar este ejemplo, pegue el siguiente código en un nuevo formulario.

Visual Basic
' 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
C#
// 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;
        }
    }

}
J#
// Create a new form.
private Form mdiChildForm = new Form();

private void Form1_Load(Object sender, System.EventArgs e)
{
    // Set the IsMdiContainer property to true.
    set_IsMdiContainer(true);

    // Set the child form's MdiParent property to 
    // the current form.
    mdiChildForm.set_MdiParent(this);

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

private void SetBackGroundColorOfMDIForm()
{
    for (int iCtr = 0; iCtr < this.get_Controls().get_Count(); iCtr++) {
        Control ctl = this.get_Controls().get_Item(iCtr);
        if (ctl instanceof MdiClient) {
            // If the control is the correct type,
            // change the color.
            ctl.set_BackColor(System.Drawing.Color.get_PaleGreen());
        }
    }
} //SetBackGroundColorOfMDIForm
Plataformas

Windows 98, Windows 2000 Service Pack 4, Windows CE, Windows Millennium, Windows Mobile para Pocket PC, Windows Mobile para Smartphone, Windows Server 2003, Windows XP Media Center, Windows XP Professional x64, Windows XP SP2, Windows XP Starter

Microsoft .NET Framework 3.0 es compatible con Windows Vista, Microsoft Windows XP SP2 y Windows Server 2003 SP1.

Información de versión

.NET Framework

Compatible con: 3.0, 2.0, 1.1, 1.0
Vea también

Page view tracker