C#WinForm 窗体回车替换Tab

时间:2023-03-09 01:29:11
C#WinForm  窗体回车替换Tab
 /// <summary>
/// 回车切换控件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void FrmDataCheckRule_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar ==)
{
if ((ActiveControl is TextBoxX))
{
//textBoxX可多行操作时不跳转
if (!(ActiveControl as TextBoxX).Multiline)
System.Windows.Forms.SendKeys.Send("{tab}");
}
else
System.Windows.Forms.SendKeys.Send("{tab}"); // MessageBox.Show(ActiveControl.Name);
}
}

加代码前

this.KeyPreview = true;