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

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

posted on 2019-09-01 22:40  万马阳光  阅读(3913)  评论(0编辑  收藏  举报