NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

Form.ActiveForm

Gets the currently active form for this application.

[Visual Basic]
Public Shared ReadOnly Property ActiveForm As Form
[C#]
public static Form ActiveForm {get;}
[C++]
public: __property static Form* get_ActiveForm();
[JScript]
public static function get ActiveForm() : Form;

Property Value

A Form that represents the currently active form, or a a null reference (in Visual Basic Nothing) if there is no active form.

Remarks

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.

Example [C#]

The following example gets the active form and makes all of the controls on the form disabled. The example uses the Controls collection of the form to iterate through each control on the form and disable the contriols.

[C#]

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;
   }
}

See Also

Form Class | Form Members | System.WinForms Namespace | ActiveMDIChild