DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 4 of 4
  1. #1
    Ingo Guest

    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.



  2. #2
    Mattias Sjögren Guest

    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.

  3. #3
    Bruce Guest

    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


    >



  4. #4
    Michael Culley Guest

    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



Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


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


Sponsored Links