Share via


Form.IsMdiContainer Properti

Definisi

Mendapatkan atau menetapkan nilai yang menunjukkan apakah formulir tersebut adalah kontainer untuk formulir turunan antarmuka multi-dokumen (MDI).

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

Nilai Properti

true jika formulir adalah kontainer untuk bentuk anak MDI; jika tidak, false. Default adalah false.

Contoh

Contoh berikut menunjukkan penggunaan IsMdiContainer properti serta mengubah BackColor properti Formulir MDI. Untuk menjalankan contoh ini, tempelkan kode berikut dalam formulir baru.


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

Keterangan

Properti ini mengubah tampilan dan perilaku formulir menjadi formulir induk MDI. Ketika properti ini diatur ke true, formulir menampilkan area klien yang tenggelam dengan batas yang dinaikkan. Semua formulir turunan MDI yang ditetapkan ke formulir induk ditampilkan dalam area kliennya.

Ketika formulir induk MDI ditutup, Closing peristiwa semua formulir anak MDI dimunculkan sebelum acara formulir Closing induk MDI dinaikkan. Selain itu, Closed peristiwa semua bentuk anak MDI dimunculkan sebelum Closed peristiwa formulir induk MDI dimunculkan.

Catatan

Jika ada dua MenuStrip kontrol pada formulir turunan MDI, pengaturan IsMdiContainer ke true untuk formulir induk menggabungkan konten hanya dari salah MenuStrip satu kontrol. Gunakan Merge untuk menggabungkan konten kontrol anak MenuStrip tambahan pada formulir induk MDI.

Berlaku untuk

Lihat juga