How do I check if a window has been opened? If it has been opened, bring it forward, otherwise open a new window. That is, I need to control the windows, checking them so that only one is open.
How do I check if a window has been opened? If it has been opened, bring it forward, otherwise open a new window. That is, I need to control the windows, checking them so that only one is open.
Easy. In the event where you are currently opening the window, place the following condition:
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim fEncontrou As Boolean = False
For Each f As Form In Application.OpenForms
If f.Name = "Form2" Then
fEncontrou = True
f.BringToFront()
f.Activate()
Exit For
End If
Next
If Not fEncontrou Then Form2.Show()
End Sub