Http://blog.csdn.net/diyoosjtu/article/details/7583515
The buttons in winform need to respond to the carriage return event, which is very simple! You only need to set the attribute in the form!
For example, if you have a login form (form_login) that contains two buttons (btnlogin) and two buttons (btnexit), and want to log on (btnlogin) to respond to the Enter key, thenSet the form (form_login) attribute acceptbutton to btnloginYou can! That isForm_login.acceptbutton = btnlogin;
Similarly,Set the cancelbutton attribute of the form (form_login)Btnexit, you can respond to the ESC key!That isForm_login.cancelbutton = btnexit;
The buttons in winform need to respond to the carriage return event, which is very simple! You only need to set the attribute in the form!
For example, if you have a login form (form_login) that contains two buttons (btnlogin) and two buttons (btnexit), and want to log on (btnlogin) to respond to the Enter key, thenSet the form (form_login) attribute acceptbutton to btnloginYou can! That isForm_login.acceptbutton = btnlogin;
Similarly,Set the cancelbutton attribute of the form (form_login)Btnexit, you can respond to the ESC key!That isForm_login.cancelbutton = btnexit;