C#:按下Enter键,自动执行Button1按钮

private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == ' ') //判断是否按下Enter键
button1.Focus(); //将鼠标焦点移到"查询"按钮上
}

原文地址:https://www.cnblogs.com/sunnywam/p/11444078.html