-
Setting a form = nothing
I have two forms: MDIForm and ChildForm.
To open the child form from the MDI I do:
Dim f As frmChildForm
If IsNothing(f) Then
f = New frmChildForm()
f.MdiParent = Me
End If
f.Show()
where f is a module variable.
But if I close the ChildForm whith Me.Close and then I try to open it
again, I get problem, because f si not Nothing.
From the other site, I cannot remove the IF...THEN that avoids two
instances of the same form.
Any suggestion?
Thank you.
-
Re: Setting a form = nothing
Ingo,
>Any suggestion?
If IsNothing(r) OrElse f.IsDisposed Then ...
Mattias
===
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/
Please reply only to the newsgroup.
-
Re: Setting a form = nothing
"Ingo" <ingo_na@hotmail.com> wrote:
>I have two forms: MDIForm and ChildForm.
>
>To open the child form from the MDI I do:
>
>Dim f As frmChildForm
> If IsNothing(f) Then
> f = New frmChildForm()
> f.MdiParent = Me
> End If
> f.Show()
>
>where f is a module variable.
>
>But if I close the ChildForm whith Me.Close and then I try to open it
>again, I get problem, because f si not Nothing.
>From the other site, I cannot remove the IF...THEN that avoids two
>instances of the same form.
>
>Any suggestion?
>
>Thank you.
>
Try this:
If IsNothing(f) Then
f = New frmChildForm()
f.MdiParent = Me
f.Show()
ElseIf not f.visible then
f = New frmChildForm()
f.MdiParent = Me
f.Show()
End If
>
-
Re: Setting a form = nothing
I've never tried this but this was one idea I came up with for this
situation
Create a public static variable on frmChild called SingleInstance (or
whatever you like)
When the form loads set Me to SingleInstance
When it closes set SingleInstance to nothing
When starting the form check if frmChild.SingleInstance is nothing.
--
Michael Culley
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
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks