Freigeben über


Form.ActiveForm-Eigenschaft

Ruft das momentan aktive Formular für diese Anwendung ab.

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

Syntax

'Declaration
Public Shared ReadOnly Property ActiveForm As Form
'Usage
Dim value As Form

value = Form.ActiveForm
public static Form ActiveForm { get; }
public:
static property Form^ ActiveForm {
    Form^ get ();
}
/** @property */
public static Form get_ActiveForm ()
public static function get ActiveForm () : Form

Eigenschaftenwert

Eine Form, die das momentan aktive Formular darstellt, oder NULL (Nothing in Visual Basic), wenn kein Formular aktiv ist.

Hinweise

Mit dieser Methode können Sie einen Verweis auf das momentan aktive Formular abrufen, um Vorgänge für das Formular oder dessen Steuerelemente durchzuführen.

Wenn es sich bei der Anwendung um eine MDI (Multiple Document Interface)-Anwendung handelt, verwenden Sie die ActiveMdiChild-Eigenschaft, um das momentan aktive untergeordnete MDI-Formular abzurufen.

Beispiel

Im folgenden Codebeispiel wird das aktive Formular abgerufen, und alle Steuerelemente im Formular werden deaktiviert. Im Beispiel wird die Controls-Auflistung des Formulars zum Durchlaufen aller Steuerelemente im Formular und zum Deaktivieren der Steuerelemente verwendet.

Public Sub DisableActiveFormControls()
    ' Create an instance of a form and assign it the currently active form.
    Dim currentForm As Form = Form.ActiveForm
    
    ' Loop through all the controls on the active form.
    Dim i As Integer
    For i = 0 To currentForm.Controls.Count - 1
        ' Disable each control in the active form's control collection.
        currentForm.Controls(i).Enabled = False
    Next i
End Sub 'DisableActiveFormControls
public void DisableActiveFormControls()
 {
    // Create an instance of a form and assign it the currently active form.
    Form currentForm = Form.ActiveForm;
    
    // Loop through all the controls on the active form.
    for (int i = 0; i < currentForm.Controls.Count; i++)
    {
       // Disable each control in the active form's control collection.
       currentForm.Controls[i].Enabled = false;
    }
 }
    
void DisableActiveFormControls()
{
   
   // Create an instance of a form and assign it the currently active form.
   Form^ currentForm = Form::ActiveForm;
   
   // Loop through all the controls on the active form.
   for ( int i = 0; i < currentForm->Controls->Count; i++ )
   {
      
      // Disable each control in the active form's control collection.
      currentForm->Controls[ i ]->Enabled = false;

   }
}
public void DisableActiveFormControls()
{
    // Create an instance of a form and assign it the currently 
    // active form.
    Form currentForm = Form.get_ActiveForm();

    // Loop through all the controls on the active form.
    for (int i = 0; i < currentForm.get_Controls().get_Count(); i++) {
        // Disable each control in the active form's control collection.
        currentForm.get_Controls().get_Item(i).set_Enabled(false);
    }
} //DisableActiveFormControls

.NET Framework-Sicherheit

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
ActiveMdiChild