Re: Weird Behavior in ShowDialog()

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: Herfried K. Wagner [MVP] (hirf-spam-me-here_at_gmx.at)
Date: 12/16/04


Date: Thu, 16 Dec 2004 08:10:22 +0100


"Sean" <anonymous@discussions.microsoft.com> schrieb:
> I have a main window application Form A that calls
> ShowDialog() of Form B in the Click event of Form A.
>
> Sometimes when I hit the cancel button on Form B, Form B
> closes and SURPRISINGLY Form A closes as well (ie. the
> whole application exits).

Maybe assigning 'None' to the button's 'DialogResult' and adding this code
to the button's 'Click' event handler solves the problem:

\\\
Me.DialogResult = DialogResult.Cancel
Me.Close()
///

-- 
 M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
 V B   <URL:http://dotnet.mvps.org/dotnet/faqs/> 

Quantcast