C#WinForm 窗体回车替换Tab

 /// <summary>
 /// 回车切换控件
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void FrmDataCheckRule_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar ==13)
            {
                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;

 

posted @ 2018-08-15 11:22  伪装大牛  阅读(332)  评论(0)    收藏  举报