I have an Mdiform which with help of menustrip opens Form1.
From this form(Form1) I open another form i.e Form2.which I want also to be a part of my mdiform
I created property of mdiform and mapped it in my form2 when it loads.but still it does not become a part of mdiform.
Another problem is ,it keeps generating new instances of form2 whenever I again click button in form1,which is child of my mdiform.I want that only single instance of form2 should be visible.
I tried doing different ways but still generates new instances.
Can anyone explain this?
Thanks in advance
srm2010 -1 Newbie Poster
Recommended Answers
Jump to PostSo you need to check if already an instance of form is opened or not.. u can use singleton pattern.
Jump to PostTry something like this..
Private Shared _Instance As Form2 = Nothing
Public Shared Function Instance() As Boolean If _Instance Is Nothing OrElse _Instance.IsDisposed = True Then _Instance = New Form2 Return False End If _Instance.BringToFront() Return True End Function
In calling form write this
…
All 7 Replies
codeorder 197 Nearly a Posting Virtuoso
srm2010 -1 Newbie Poster
codeorder 197 Nearly a Posting Virtuoso
Pgmer 50 Master Poster Featured Poster
Pgmer 50 Master Poster Featured Poster
srm2010 -1 Newbie Poster
Pgmer 50 Master Poster Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.