I don't (yet) want pressing the Cancel button to not close the form, but that wasn't my question. WinForms has a nice architecture for setting the DialogResult for a button and either having the form close or not when the button is pressed based on whether they DialogResult property for that button is set, but they had to go and special case it for Cancel. Seems like a waste of a perfectly good architecture.
Chris ----- Original Message ----- From: "Ian Griffiths" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Tuesday, June 11, 2002 2:49 AM Subject: Re: [DOTNET] Why is CancelButton special? > As far as I can tell the purpose of having a CancelButton is to close the > form for you automatically whatever. If you don't want this behaviour don't > assign a CancelButton! > > By the way having the DialogResult as None is handled as a special case. If > you set the DialogResult to be anything else then Windows Forms will return > whatever you specify as the DialogResult. But if your CancelButton > specifies None it returns Cancel anyway! (But I think it always closes the > form.) > > Why do you want something to be a CancelButton but not have it close the > form? Is there something else that CancelButton does for you? > > -- > Ian Griffiths > DevelopMentor > > ----- Original Message ----- > From: "Chris Sells" <[EMAIL PROTECTED]> > > > > If I set the AcceptButton to a button whose DialogResult is set to None, > > pressing that button does not automatically close the form. > > > > However, if I set the CancelButton to a button whose DialogResult is set > > to None, pressing the button *does* automatically close the form and I > > don't see any way to halt this process, even if I've got an event > > handler for that button. Why is that? You can read messages from the DOTNET archive, unsubscribe from DOTNET, or subscribe to other DevelopMentor lists at http://discuss.develop.com.