Freigeben über


Form.IsMdiContainer-Eigenschaft

Ruft einen Wert ab, der angibt, ob das Formular ein Container für untergeordnete MDI (Multiple Document Interface)-Formulare ist, oder legt diesen fest.

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in system.windows.forms.dll)

Syntax

'Declaration
Public Property IsMdiContainer As Boolean
'Usage
Dim instance As Form
Dim value As Boolean

value = instance.IsMdiContainer

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

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

public function set IsMdiContainer (value : boolean)

Eigenschaftenwert

true, wenn das Formular ein Container für untergeordnete MDI-Formulare ist, andernfalls false. Der Standardwert ist false.

Hinweise

Diese Eigenschaft verleiht dem Formular Darstellung und Verhalten eines übergeordneten MDI-Formulars. Wenn diese Eigenschaft auf true festgelegt ist, wird im Formular ein abgesenkter Clientbereich mit angehobenem Rahmen angezeigt. Alle untergeordneten MDI-Formulare, die dem übergeordneten Formular zugewiesen sind, werden in dessen Clientbereich angezeigt.

Wenn ein übergeordnetes MDI-Formular geschlossen wird, werden die Closing-Ereignisse aller untergeordneten MDI-Formulare ausgelöst, bevor das Closing-Ereignis des übergeordneten MDI-Formulars ausgelöst wird. Außerdem werden die Closed-Ereignisse aller untergeordneten MDI-Formulare ausgelöst, bevor das Closed-Ereignis des übergeordneten MDI-Formulars ausgelöst wird.

Beispiel

Im folgenden Codebeispiel wird das Verwenden der IsMdiContainer-Eigenschaft und das Ändern der BackColor-Eigenschaft eines MDI-Formulars veranschaulicht. Fügen Sie zum Ausführen des Beispiels folgenden Code in ein neues Formular ein.

' 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
// 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.
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

Plattformen

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile für Pocket PC, Windows Mobile für Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.

Versionsinformationen

.NET Framework

Unterstützt in: 2.0, 1.1, 1.0

Siehe auch

Referenz

Form-Klasse
Form-Member
System.Windows.Forms-Namespace
Form.IsMdiChild-Eigenschaft
MdiParent
MdiChildren