If one of the two buttons is the close or cancel button, you can set the CancelButton property of the form to that button and it will handle it for you.
Regards, Ruffnekk
---
Is it my imagination or do buffalo wings taste just like chicken?
this.Close() would only be neccesary if the form is the startup form for the solution. If the form was shown by calling .ShowDialog() then you can omit that part.
Regards, Ruffnekk
---
Is it my imagination or do buffalo wings taste just like chicken?
the CancelButton property makes c# act as if the button has been clicked when the user presses the escape key.
imho a dialog should always have a Cancel button.
and, for the sake of consistency, a Cancel button and pressing the escape key should do the same thing.
if you don't want a Cancel button on the form, ask yourself what users who don't know that pressing Escape cancels dialogs will do. for certain they'll go to task manager and kill the process. *shudder*.
sorry ruffnekk, i didn't mean to seem to contradict you, my post was aimed at the last one by PIAS.
why is it that setting CancelButton sets DialogResult, but AcceptButton doesn't?
*if a button has DialogResult set, and its parent form is shown using the ShowDialog() method, clicking it will close the form returning its DialogResult.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.