On any Win Form you can designate a Button control to be the cancel button. A cancel button is clicked whenever the user presses the ESC key, regardless of which other control on the form has the focus. Such a button is usually programmed to allow the user to quickly exit an operation without committing to any action.
You can programmatically set a button as the cancel button.
To designate the cancel button programmatically
[Visual Basic] Private Sub SetCancelButton(myCancelBtn As Button) Set Me.CancelButton = myCancelBtn End Sub [C#] [MC++]
Button Control | Selecting a Button Control Programmatically | Responding to Button Clicks | CancelButton Property | Designating a Button As the Accept Button