Checking if a form has been already open

  • Thread starter Thread starter Dino M. Buljubasic
  • Start date Start date
D

Dino M. Buljubasic

I'd like to check if a form is already open before opening it and if it is
not, then open it, otherwise just make it the active form.

How can I do that?

Regards,
Dino
 
Dino M. Buljubasic said:
I'd like to check if a form is already open before opening it and if
it is not, then open it, otherwise just make it the active form.

How can I do that?

Private m_OtherForm As Form1

Private Sub OpenForm1()
If m_OtherForm Is Nothing Then
m_OtherForm = New Form1
AddHandler m_OtherForm.Closed, AddressOf OnOtherFormClosed
m_OtherForm.Show()
End If
m_OtherForm.Activate()
End Sub

Private Sub OnOtherFormClosed( _
ByVal sender As Object, ByVal e As System.EventArgs)

RemoveHandler m_OtherForm.Closed, AddressOf OnOtherFormClosed
m_OtherForm = Nothing
End Sub
 
Dino M. Buljubasic said:
I'd like to check if a form is already open before opening it and if it is
not, then open it, otherwise just make it the active form.

Hi Dino... not a problem but I'm curious if you scan down the properties for
a form in the help. By that I only mean it can be a quick way to get an
answer... and I always find something new in there I didn't know while I am
looking for something else.

How about the .Visible property?

Tom
 
Back
Top