Visual Basic 2005 in a Nutshell (In a Nutshell (OReilly))

OpenForms Property

Location

My.Application.OpenForms

Syntax

Dim result As System.Windows.Forms.FormCollection = _ My.Application.OpenForms

Description

The OpenForms property returns a collection of the application's currently open forms.

Usage at a Glance

  • This property is read-only.

  • This property is only valid in Windows Forms applications.

  • An exception may be thrown if you try to access a form opened by another thread of your application. This property returns all forms currently open by all threads of the application. You may be limited in which open forms you can access from the current thread. For a given form, examine the System.Windows.Forms.Control.InvokeRequired property, which returns true if the form was created by another thread. If true, you can access that form by using its System.Windows.Forms.Control.Invoke method.

Example

The following code saves the location of each form to the application's area of the registry.

Dim scanForm As System.Windows.Forms.Form For Each scanForm In My.Application.OpenForms SaveSetting("MySoftware", "FormPositions", _ TypeName(scanForm), scanForm.Left & "," & scanForm.Top) Next scanForm

Related Framework Entries

  • Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OpenForms Property

  • System.Windows.Forms.Application.OpenForms Property

See Also

Application Object, SplashScreen Property

Категории