opening form only one time

M

mf_sina

Which is the best way to prevent opening a form which is already open?
my program has an mdiparent form and when the user opens frmcustomers, can
edit records.
now if the user again opens this form a new instance will be created and the
same form opens again.
what i can do to prevent this?
I'm using VB .Net and winxp
 
H

Herfried K. Wagner [MVP]

mf_sina said:
Which is the best way to prevent opening a form which is already open?
my program has an mdiparent form and when the user opens frmcustomers, can
edit records.
now if the user again opens this form a new instance will be created and
the same form opens again.
what i can do to prevent this?

\\\
Private WithEvents m_TheChild As Form1

Private Sub m_TheChild_Closed( _
ByVal sender As Object, _
ByVal e As EventArgs _
) Handles m_TheChild.Closed
m_TheChild = Nothing
Me.Button1.Enabled = True
End Sub

Private Sub Button1_Click( _
ByVal sender As Object, _
ByVal e As EventArgs _
) Handles Button1.Click
Me.Button1.Enabled = False
m_TheChild = New Form1
m_TheChild.MdiParent = Me
m_TheChild.Show()
End Sub
///
 

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