Form.ActiveMdiChild Property
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets the currently active multiple-document interface (MDI) child window.
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
Returns a Form that represents the currently active MDI child window, or null
if there are currently no child windows present.
- Attributes
The following example obtains a reference to the active MDI child form and loops through all TextBox controls on the form, resetting their Text properties. This example requires that an MDI parent form has been created and that this method call is being made from the MDI parent form.
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
You can use this method to determine whether there are any MDI child forms open in your MDI application. You can also use this method to perform operations on an MDI child window from its MDI parent form or from another form that is displayed in your application.
If the currently active form is not an MDI child form, you can use the ActiveForm property to obtain a reference to it.
제품 | 버전 |
---|---|
.NET Framework | 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
Windows Desktop | 3.0, 3.1, 5, 6, 7, 8, 9 |
.NET 피드백
.NET은(는) 오픈 소스 프로젝트입니다. 다음 링크를 선택하여 피드백을 제공해 주세요.