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 [ .NET MVP | weblog: http://radio.weblogs.com/0104813/ ] > -----Original Message----- > From: Chris Sells [mailto:[EMAIL PROTECTED]] > Sent: Tuesday, June 11, 2002 10:53 AM > To: [EMAIL PROTECTED] > Subject: Re: Why is CancelButton special? > > > > Usually a form can be stopped from closing by > > handling the event which occurs when cancel button is > > clicked . This is possible in VB . I presume it should > > be possible in .Net > > > You can read messages from the DOTNET archive, unsubscribe > from DOTNET, or subscribe to other DevelopMentor lists at > http://discuss.develop.com. > You can read messages from the DOTNET archive, unsubscribe from DOTNET, or subscribe to other DevelopMentor lists at http://discuss.develop.com.