当前位置:首页 > C#中Windows通用的回车转Tab方法

C#中Windows通用的回车转Tab方法

点击次数:1514  更新日期:2010-12-24
\n

原来一直是为每个文本框的KeyPress增加:
\n

if(e.KeyChar = ‘\\r’) SendKeys.Send(“{TAB}”);


\n

  最近想想,其实有更简单的方法,把Form的KeyPreView设为true,然后在Form的KeyPress中增加下列代码即可:


\n

if (e.KeyChar == ‘\\r’)
this.SelectNextControl(this.ActiveControl, true, true, true, true);

\n

来源:网络

\n