C keyboard input enter key to achieve button click effect method
- 2020-10-31 21:57:56
- OfStack
The example of this paper describes the C# keyboard input enter key to achieve button click effect method, C# project development is very practical value. Share to everybody for everybody reference.
Specific implementation methods are as follows:
Set KeyPreview for Form to true
Then set the KeyDown, KeyUp, or KeyPress events. Intercepted in the KeyDown event.
The main function codes are as follows:
this.KeyDown += new KeyEventHandler(textBox1_KeyDown);
private void textBox1_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
this.L_login.Focus();
L_login_Click(this,new EventArgs());
}
}
I hope this article has helped you with your C# programming.