Solved

closing winform

Posted on 2009-03-30
6
405 Views
Last Modified: 2013-12-17
Can open a 2nd WinForm via the 1st main WinForm.

Created an association (ownership) between the 1st and newly opened 2nd WinForm

The scripting also checks to see if the WinForm has been opened already ... this works (appears too).

Issue is:  when closing the 2nd WinForm and then wanting to open it again I call the opening WinForm script again -- but I cannot reopen the WinForm (once closed) -- I suspect it has something to with the formBrowser  null  status.

How do I reset this parameter or get working correctly?
// WinForm #1
 

FormBrowser formBrowser;
 
 

if (formBrowser != null) return;
 

formBrowser = new FormBrowser { Owner = this };

formBrowser.Show();

Open in new window

0
Comment
Question by:amillyard
6 Comments
 
LVL 15

Expert Comment

by:angus_young_acdc
ID: 24018064
Have you put in a breakpoint to see if formBrowser is null?  
0
 

Author Comment

by:amillyard
ID: 24018331
angus_young_acdc:  checking the breakpoint ... null the 1st time called.  the 2nd onwards is not displayed as null, but is soft of empty !   when disposing the WinForm, it is not resetting back to null status
0
 
LVL 9

Expert Comment

by:VikramMullick
ID: 24018551
try
formBrowser.Showdialog(this)
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
LVL 69

Assisted Solution

by:Éric Moreau
Éric Moreau earned 200 total points
ID: 24018561
you should check for null or IsDisposed
0
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 300 total points
ID: 24018587
It won't. Closing the form will not nullify the variable that was pointing to it.

You are best to check for null, or if the form is Disposed:
        private void button1_Click(object sender, EventArgs e)

        {

            if (f == null || f.IsDisposed)

                f = new Form5();
 

            f.Show();

        }
 

        Form5 f = null;

Open in new window

0
 

Author Closing Comment

by:amillyard
ID: 31564285
carl_tawn: & emoreau:  works great now :-)   many thanks.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…
Delivering innovative fully-managed cloud services for mission-critical applications requires expertise in multiple areas plus vision and commitment. Meet a few of the people behind the quality services of Concerto.

914 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now