Solved

closing winform

Posted on 2009-03-30
6
407 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
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 
LVL 70

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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Summary Displaying images in RichTextBox is a common requirement with limited solutions available. Pasting through clipboard or embedding into RTF content only support static images.  This article describes how to insert Windows control objects int…
Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

803 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