Enter key to default to OK button.

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

This is for a Win form.

On my Win Form, I have a data grid, OK button and a Cancel button.
The focus is in the data grid and when the user hits enter, I want the OK
button code to be called.
 
Set the AcceptButton property of the form to your OK button.

Also, because you have a Cancel button, perhaps you want to set the forms
CancelButton property to your cancel button so that pressing the escape key
will trigger it.

Both of these are often used when you build a dialog and sound perfect for
what you are doing.

Brendan
 
Back
Top