Form.ActiveMdiChild Properti
Definisi
Penting
Beberapa informasi terkait produk prarilis yang dapat diubah secara signifikan sebelum dirilis. Microsoft tidak memberikan jaminan, tersirat maupun tersurat, sehubungan dengan informasi yang diberikan di sini.
Mendapatkan jendela anak antarmuka multi-dokumen (MDI) yang saat ini aktif.
public:
property System::Windows::Forms::Form ^ ActiveMdiChild { System::Windows::Forms::Form ^ get(); };
[System.ComponentModel.Browsable(false)]
public System.Windows.Forms.Form ActiveMdiChild { get; }
[System.ComponentModel.Browsable(false)]
public System.Windows.Forms.Form? ActiveMdiChild { get; }
[<System.ComponentModel.Browsable(false)>]
member this.ActiveMdiChild : System.Windows.Forms.Form
Public ReadOnly Property ActiveMdiChild As Form
Nilai Properti
Mengembalikan Form yang mewakili jendela anak MDI yang saat ini aktif, atau null jika saat ini tidak ada jendela anak.
- Atribut
Contoh
Contoh berikut mendapatkan referensi ke formulir anak MDI aktif dan perulangan melalui semua TextBox kontrol pada formulir, mengatur ulang propertinya Text . Contoh ini mengharuskan formulir induk MDI telah dibuat dan bahwa panggilan metode ini sedang dilakukan dari formulir induk MDI.
public:
void ClearAllChildFormText()
{
// Obtain a reference to the currently active MDI child form.
Form^ tempChild = this->ActiveMdiChild;
// Loop through all controls on the child form.
for ( int i = 0; i < tempChild->Controls->Count; i++ )
{
// Determine if the current control on the child form is a TextBox.
if ( dynamic_cast<TextBox^>(tempChild->Controls[ i ]) )
{
// Clear the contents of the control since it is a TextBox.
tempChild->Controls[ i ]->Text = "";
}
}
}
public void ClearAllChildFormText()
{
// Obtain a reference to the currently active MDI child form.
Form tempChild = this.ActiveMdiChild;
// Loop through all controls on the child form.
for (int i = 0; i < tempChild.Controls.Count; i++)
{
// Determine if the current control on the child form is a TextBox.
if (tempChild.Controls[i] is TextBox)
{
// Clear the contents of the control since it is a TextBox.
tempChild.Controls[i].Text = "";
}
}
}
Public Sub ClearAllChildFormText()
' Obtain a reference to the currently active MDI child form.
Dim tempChild As Form = Me.ActiveMdiChild
' Loop through all controls on the child form.
Dim i As Integer
For i = 0 To tempChild.Controls.Count - 1
' Determine if the current control on the child form is a TextBox.
If TypeOf tempChild.Controls(i) Is TextBox Then
' Clear the contents of the control since it is a TextBox.
tempChild.Controls(i).Text = ""
End If
Next i
End Sub
Keterangan
Anda dapat menggunakan metode ini untuk menentukan apakah ada formulir anak MDI yang terbuka di aplikasi MDI Anda. Anda juga dapat menggunakan metode ini untuk melakukan operasi pada jendela anak MDI dari formulir induk MDI atau dari formulir lain yang ditampilkan di aplikasi Anda.
Jika formulir yang saat ini aktif bukan formulir anak MDI, Anda dapat menggunakan ActiveForm properti untuk mendapatkan referensi ke formulir tersebut.