Condividi tramite


Form.ActiveMdiChild Proprietà

Definizione

Ottiene la finestra figlio MDI (Multiple Document Interface) attualmente attiva.

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

Valore della proprietà

Restituisce un oggetto Form che rappresenta la finestra figlio MDI attualmente attiva o null se attualmente non sono presenti finestre figlio.

Attributi

Esempio

Nell'esempio seguente viene ottenuto un riferimento alla maschera figlio MDI attiva e viene eseguito un ciclo in tutti i TextBox controlli del modulo, reimpostando Text le relative proprietà. Questo esempio richiede che sia stato creato un modulo padre MDI e che la chiamata al metodo venga eseguita dal modulo padre 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

Commenti

È possibile usare questo metodo per determinare se sono presenti moduli figlio MDI aperti nell'applicazione MDI. È anche possibile utilizzare questo metodo per eseguire operazioni su una finestra figlio MDI dal modulo padre MDI o da un altro modulo visualizzato nell'applicazione.

Se il modulo attualmente attivo non è un modulo figlio MDI, è possibile utilizzare la ActiveForm proprietà per ottenere un riferimento.

Si applica a

Vedi anche