把Form的KeyPreview设为true
然后设置KeyDown,KeyUp或KeyPress事件。在KeyDown事件中截获。
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());
}
}