2
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.
2
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.
1
Easy. In the event 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
Browser other questions tagged c# winforms
You are not signed in. Login or sign up in order to post.
Explain better what you want to know. You want to control so that only one application instance is opened?
– Gabriel Brito
http://sanity-free.org/143/csharp_dotnet_single_instance_application.html
– Tony