Form.ActiveMdiChild Właściwość

Definicja

Pobiera obecnie aktywne okno podrzędne interfejsu wielu dokumentów (MDI).

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

Wartość właściwości

Form

Zwraca wartość reprezentującą Form aktualnie aktywne okno podrzędne MDI lub null jeśli obecnie nie ma żadnych okien podrzędnych.

Atrybuty

Przykłady

Poniższy przykład uzyskuje odwołanie do aktywnego formularza podrzędnego MDI i wykonuje pętle za pośrednictwem wszystkich TextBox kontrolek w formularzu, resetując ich Text właściwości. Ten przykład wymaga utworzenia formularza nadrzędnego MDI i utworzenia tego wywołania metody z formularza nadrzędnego 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

Uwagi

Tej metody można użyć do określenia, czy w aplikacji MDI są otwarte jakiekolwiek formularze podrzędne MDI. Za pomocą tej metody można również wykonywać operacje w oknie podrzędnym MDI z formularza nadrzędnego MDI lub z innego formularza wyświetlanego w aplikacji.

Jeśli obecnie aktywny formularz nie jest formularzem podrzędnym MDI, możesz użyć ActiveForm właściwości w celu uzyskania odwołania do niego.

Dotyczy

Zobacz też