C# 按回车等同于按“Tab”或者点击按钮

版权声明:随便看,喜欢的话加我qq,一起讨论。 https://blog.csdn.net/qq_43687284/article/details/84297083
//按回车等同于按“Tab”
private void textBox1_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e) 

{ 
     if(e.KeyChar == (char)13) 
     { 
         SendKeys.Send("{Tab}"); 
  } 
}
//按回车等同于点击按钮
if (e.KeyChar.Equals('\r'))
	{
		button1.PerformClick();
}

猜你喜欢

转载自blog.csdn.net/qq_43687284/article/details/84297083
今日推荐