|
-
Jun 28th, 2003, 03:05 AM
#1
Thread Starter
New Member
checking previous instance of form
Hello,
I have a form1,from the context menu i am calling the form2
The form2 is loaded fine.Once again if i am again accessing
the context menu clicking.One more copy of form2 is loaded.
If the previous instance of form2 is loaded and active.
Then i do not want to load it again.
How to do this in vb.net.It is easy for me in vb6.
Thanks and regards
shawlin
-
Jun 28th, 2003, 06:50 AM
#2
Addicted Member
many ways -
Check if the form Is Nothing before (re)loading it. Use the FindWindow API function, Create the form using the singleton design pattern OR simply have an callback to Form1 from Form2 which disables/enables the menuitem when Form2 is loaded/unloaded.
I think this was discussed in previous threads - do a search
Cheers
-
Jun 28th, 2003, 09:37 AM
#3
Sleep mode
Re: checking previous instance of form
If you want to check for form instances , something like this would work :
VB Code:
'put this in the general declaration form
Dim FRM2 As New Form 'or if you have another form replace it here
Private Sub Button1_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles Button1.Click
If Not FRM2 Is Nothing Then 'allows one instance of the form named Form
FRM2.Show()
Else
FRM2 = Nothing
End If
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|