Form.ActiveForm Eigenschap

Definitie

Hiermee haalt u het actieve formulier voor deze toepassing op.

public:
 static property System::Windows::Forms::Form ^ ActiveForm { System::Windows::Forms::Form ^ get(); };
public static System.Windows.Forms.Form ActiveForm { get; }
static member ActiveForm : System.Windows.Forms.Form
Public Shared ReadOnly Property ActiveForm As Form

Waarde van eigenschap

Een Form formulier dat het huidige actieve formulier vertegenwoordigt of null als er geen actief formulier is.

Voorbeelden

In het volgende voorbeeld wordt het actieve formulier weergegeven en worden alle besturingselementen op het formulier uitgeschakeld. In het voorbeeld wordt de Controls verzameling van het formulier gebruikt om elk besturingselement in het formulier te doorlopen en de besturingselementen uit te schakelen.

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.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 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

Opmerkingen

U kunt deze methode gebruiken om een verwijzing naar het momenteel actieve formulier te verkrijgen om acties uit te voeren op het formulier of de besturingselementen ervan.

Als uw toepassing een MDI-toepassing (Multiple-Document Interface) is, gebruikt u de ActiveMdiChild eigenschap om het actieve onderliggende MDI-formulier te verkrijgen.

Van toepassing op

Zie ook