This documentation is archived and is not being maintained.

WindowsFormsApplicationBase.OpenForms Property

Gets a collection of all the application's open forms.

Namespace:  Microsoft.VisualBasic.ApplicationServices
Assembly:  Microsoft.VisualBasic (in Microsoft.VisualBasic.dll)

public FormCollection OpenForms { get; }

Property Value

Type: System.Windows.Forms.FormCollection
A FormCollection object that contains all of the application's open forms.

The My.Application.OpenForms property gets a collection of all the application's open forms. The behavior is identical to the Application.OpenForms property.


The My.Application.OpenForms property returns all open forms, regardless of which thread opened them. You should check the InvokeRequired property of each form before accessing it; otherwise, it might throw an InvalidOperationException exception. For more information, see How to: Access All Open Forms of an Application (Visual Basic).

The following table lists examples of tasks involving the My.Application.OpenForms property.



Display the titles of all the application's open forms

How to: Access All Open Forms of an Application (Visual Basic)

Availability by Project Type

Project type


Windows Forms Application


Class Library


Console Application


Windows Forms Control Library


Web Control Library


Windows Service


Web Site


This example loops over the application's open forms, selects the ones directly accessible by the current thread, and displays their titles in a ListBox control. To access the open forms, see How to: Access All Open Forms of an Application (Visual Basic).

Private Sub GetOpenFormTitles()
    Dim formTitles As New Collection

        For Each f As Form In My.Application.OpenForms
            If Not f.InvokeRequired Then
                ' Can access the form directly.
            End If
    Catch ex As Exception
        formTitles.Add("Error: " & ex.Message)
    End Try

    Form1.ListBox1.DataSource = formTitles
End Sub

This example requires that your Windows Forms application have a form named Form1 that contains a list box named ListBox1.

.NET Framework

Supported in: 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

  • UIPermission 

    Controls the permissions that are related to user interfaces and the Clipboard. Associated enumeration: AllWindows.

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.