Thanks, Mark. I assumed it was a labor-saving device. Chris Sells http://www.sellsbrothers.com/
> -----Original Message----- > From: The DOTNET list will be retired 7/1/02 > [mailto:[EMAIL PROTECTED]] On Behalf Of Mark Boulter > Sent: Tuesday, June 11, 2002 8:27 AM > To: [EMAIL PROTECTED] > Subject: Re: [DOTNET] Why is CancelButton special? > > There is code in the CancelButton setter that sets the DialogResult of > the CancelButton to Cancel if it is currently "None". > > This code is there so that if you set the CancelButton of the Form the > DialogResult for the CancelButton is automatically set to Cancel- > meaning setting up the CancelButton at designtime is a one stage > operation rather than a 2 stage operation. Unfortunately this is > inconsistent with the AcceptButton which does not have this behavior (it > did at one point and we removed it because the AcceptButton can be the > "Apply" or "Next" button). This is an unfortunate. > > As noted earlier, if you want to override this behavior set the > dialogresult of the button back to None after InitializeComponent has > run. > > Alternatively you can cancel the close using the closing event: > > private void Form1_Closing(object sender, CancelEventArgs e) { > if (textBox1.Text == "NO") { > e.Cancel = true; > } > } > > mark > -----Original Message----- > From: Chris Sells [mailto:[EMAIL PROTECTED]] > Sent: Tuesday, June 11, 2002 7:53 AM > To: [EMAIL PROTECTED] > Subject: Re: [DOTNET] 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 > > In might be possible in VB.NET, but handling the Cancel button's click > event > in WinForms does *not* stop the form from closing. > > 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. You can read messages from the DOTNET archive, unsubscribe from DOTNET, or subscribe to other DevelopMentor lists at http://discuss.develop.com.