Freigeben über


Form.ActiveMdiChild-Eigenschaft

Ruft das momentan aktive untergeordnete MDI (Multiple Document Interface)-Fenster ab.

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in system.windows.forms.dll)

Syntax

'Declaration
Public ReadOnly Property ActiveMdiChild As Form
'Usage
Dim instance As Form
Dim value As Form

value = instance.ActiveMdiChild
public Form ActiveMdiChild { get; }
public:
property Form^ ActiveMdiChild {
    Form^ get ();
}
/** @property */
public Form get_ActiveMdiChild ()
public function get ActiveMdiChild () : Form

Eigenschaftenwert

Gibt eine Form zurück, die das momentan aktive untergeordnete MDI-Fenster darstellt, oder NULL (Nothing in Visual Basic), wenn keine untergeordneten Fenster vorhanden sind.

Hinweise

Mit dieser Methode können Sie feststellen, ob untergeordnete MDI-Formulare in der MDI-Anwendung geöffnet sind. Sie können diese Methode auch verwenden, um Vorgänge für ein untergeordnetes MDI-Fenster vom übergeordneten MDI-Formular oder einem anderen, in der Anwendung angezeigten Formular aus durchzuführen.

Wenn das momentan aktive Formular kein untergeordnetes MDI-Formular ist, können Sie einen Verweis darauf mithilfe der ActiveForm-Eigenschaft abrufen.

Beispiel

Im folgenden Codebeispiel wird ein Verweis auf das aktive untergeordnete MDI-Formular abgerufen, und es werden alle TextBox-Steuerelemente im Formular durchlaufen, um dann deren Text-Eigenschaft zurückzusetzen. Für dieses Beispiel ist es erforderlich, dass ein übergeordnetes MDI-Formular erstellt wurde und dieser Methodenaufruf vom übergeordneten MDI-Formular ausgeht.

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 'ClearAllChildFormText
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:
   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.get_ActiveMdiChild();

    // Loop through all controls on the child form.
    for (int i = 0; i < tempChild.get_Controls().get_Count(); i++) {
        // Determine if the current control on the child form is a 
        // TextBox.
        if (tempChild.get_Controls().get_Item(i) instanceof TextBox) {
            // Clear the contents of the control since it is a TextBox.
            tempChild.get_Controls().get_Item(i).set_Text("");
        }
    }
} //ClearAllChildFormText

Plattformen

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile für Pocket PC, Windows Mobile für Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.

Versionsinformationen

.NET Framework

Unterstützt in: 2.0, 1.1, 1.0

Siehe auch

Referenz

Form-Klasse
Form-Member
System.Windows.Forms-Namespace
Form.ActiveForm-Eigenschaft