Gets the currently active form for this application.
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
You can use this method to obtain a reference to the currently active form to perform actions on the form or its controls.
If your application is a multiple-document interface (MDI) application, use the ActiveMdiChild property to obtain the currently active MDI child form.
The following code example gets the active form and disables all the controls on the form. The example uses the Controls collection of the form to iterate through each control on the form and disable the controls.
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
Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.