Form.ActiveMdiChild Propriété

Définition

Obtient la fenêtre enfant MDI active.

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

Valeur de propriété

Form

Retourne un Form représentant la fenêtre MDI enfant active ou null si aucune fenêtre enfant active n'est détectée.

Attributs

Exemples

L’exemple suivant obtient une référence au formulaire enfant MDI actif et effectue une boucle dans tous les TextBox contrôles du formulaire, réinitialisant leurs Text propriétés. Cet exemple exige qu’un formulaire parent MDI ait été créé et que cet appel de méthode soit effectué à partir du formulaire parent 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

Remarques

Vous pouvez utiliser cette méthode pour déterminer s’il existe des formulaires enfants MDI ouverts dans votre application MDI. Vous pouvez également utiliser cette méthode pour effectuer des opérations sur une fenêtre enfant MDI à partir de son formulaire parent MDI ou d’un autre formulaire affiché dans votre application.

Si le formulaire actif n’est pas un formulaire enfant MDI, vous pouvez utiliser la ActiveForm propriété pour obtenir une référence à celui-ci.

S’applique à

Voir aussi