Solved

closing winform

Posted on 2009-03-30
6
404 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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

IP addresses can be stored in a database in any of several ways.  These ways may vary based on the volume of the data.  I was dealing with quite a large amount of data for user authentication purpose, and needed a way to minimize the storage.   …
This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

706 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

18 Experts available now in Live!

Get 1:1 Help Now