Add a keyboard shortcut for the button in WinForm, Which is ultra-simple and effective for test purposes.
The blogger does not have much experience in program development on the Windows platform. He used MFC to design a page for a fingerprint recognition system a year ago, but never used it several times. Now C # course Lab requires a simple calculator. To facilitate quick data entry, using a keyboard is much more efficient than clicking a button with the mouse. For example, you can press the number 1 on the keypad to achieve the same effect as clicking button 1 with the mouse.
Baidu once and found almost exactly the same tutorials. There are several methods available in the blog posts reposted by csdn, but I did not know where the configuration went wrong after I tried it. Then Google clicked the first search result and StackOverFlow's Q & A successfully solved my problem.
To implement custom keyboard buttons, you only need to override the protected override bool ProcessCmdKey (ref Message msg, Keys keyData) method (function.
Protected override bool ProcessCmdKey (ref Message msg, Keys keyData) {// if it is a hotkey, return true; otherwise, return false switch (keyData) {case Keys. numPad0: // the focus is on the control button_num_0, that is, button_num_0.Focus (); // click the execute button to operate button_num_0.20.mclick (); return true; case Keys. numPad1: button_num_1.Focus (); button_num_1.20.mclick (); return true ;//...... default: break;} return base. processCmdKey (ref msg, keyData );}
For the complete project sample code, see this article: http://www.cnblogs.com/zyfdeblog/p/4567071.html:
The original Article must be included in the original article. Thank you.