Hi Geoff,

It's been suggested before, your solution, but I thought there would be
another way. Not that there is anything wrong with your idea. Anyway, I
implemented it and it is working.
Thanks,
Eddie

-----Original Message-----
From: Discussion of advanced .NET topics.
[mailto:[EMAIL PROTECTED] Behalf Of Geoff Taylor
Sent: Monday, November 27, 2006 10:47 AM
To: ADVANCED-DOTNET@DISCUSS.DEVELOP.COM
Subject: Re: [ADVANCED-DOTNET] Events fired when Form.ShowDialog is
called


How about:

using (MyDialog dialog = new MyDialog ())
{
        // Call your initialise method
        dialog.MyInitialise ();
        if (dialog.ShowDialog () == DialogResult.OK)
        {
                // Fetch my results
                results = dialog.GetMyResults ();
        }
}

So, you can add whatever initialisation you need in your MyInitialise ()
method, and get whatever values you need from your GetMyResults () method.

The 'using' statement will handle the Disposal automatically, and you're
instantiating a new MyDialog each time through the code so you shouldn't
have any problems with re-using an existing object.

As for the event that's fired every time ShowDialog is called, the only way
I've found of doing this is putting code in OnVisibleChanged, and checking
whether the form is visible or not.  I didn't really like that...

Hope this helps,

                        Geoff

P.S. that's all uncompiled 'air code', so there may be typos etc.

===================================
This list is hosted by DevelopMentorĀ®  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to