Verify if Form is already open

N

nTn

Hi!

I open a new form in my Mdi. But if I click in button again to open this
form, the program create another form.

How I can check if the form is already open?

I'm using that:

Dim frmUsuarios As New usuarios("Usuarios", Me)frmUsuarios.Show()
 
G

Guest

Use a shared function to open the form as a singleton then it will only be
created once.





..
 
G

Guest

Class Form1

Private Shared _Form As Form1

Auto Generated code ......

Public Shared Function SingltonShowForm(ByVal Title As String, ByVal Owner
As Object) As Form1

If _Form Is Nothing OrElse _Form.IsDisposed Then

_Form = New Form1

With _Form

..Text = Title

..Owner = Owner

End With

End If

_Form.Show()

Return _Form

End Function
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top