This article describes the method of entering the Enter key on the C# keyboard to achieve the button click effect, which is very practical in C# project development. Share it for your reference.
The specific implementation method is as follows:
Set the Form's KeyPreview to true
Then set the KeyDown, KeyUp, or KeyPress event. Intercepted in the KeyDown event.
The main function codes are as follows:
+= new KeyEventHandler(textBox1_KeyDown); private void textBox1_KeyDown(object sender, KeyEventArgs e) { if ( == ) { this.L_login.Focus(); L_login_Click(this,new EventArgs()); } }
I hope this article will be helpful to everyone's C# programming learning.