To check if a form is already open in C# and VB.NET you can use the following snippet.

Sample C#

public static bool IsFormOpen(Type FormType)
{
	foreach (var OpenForm in Application.OpenForms)
	{
		if (OpenForm.GetType() == FormType)
		{
			return true;
		}
	}
	return false;
}

Sample VB.NET

Public Shared Function IsFormOpen(FormType As Type) As Boolean
	For Each OpenForm As var In Application.OpenForms
		If OpenForm.GetType() = FormType Then
			Return True
		End If
	Next
	Return False
End Function

One thought on “How to check if a form is already open in C# and VB.NET”

Leave a Reply