I *can* handling OnClosing. I'm just looking to understand the
inconsistency. --Chris

----- Original Message -----
From: "Marsh, Drew" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, June 11, 2002 8:58 AM
Subject: Re: [DOTNET] Why is CancelButton special?


> Chris Sells [mailto:[EMAIL PROTECTED]] wrote:
>
> > In might be possible in VB.NET, but handling the Cancel
> > button's click event in WinForms does *not* stop the form
> > from closing.
>
> Chris,
>
> Why can't you handle OnClosing?
>
> <codeSnippet language="C#">
> protected override void OnClosing(CancelEventArgs e)
> {
>         Debug.WriteLine("closing!");
>
>         base.OnClosing(e);
>
>         if(!e.Cancel)
>         {
>                 e.Cancel = MessageBox.Show(this, "You sure you want to
> close?", "Close?", MessageBoxButtons.YesNo) == DialogResult.No;
>         }
> }
> </codeSnippet>
>
> HTH,
> Drew

You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

Reply via email to