C#中Windows通用的回车转Tab方法(收藏)
原来一直是为每个文本框的KeyPress增加:
if(e.KeyChar = 'r') SendKeys.Send("{TAB}");
最近想想,其实有更简单的方法,把Form的KeyPreView设为true,然后在Form的KeyPress中增加下列代码即可:
if (e.KeyChar == 'r')
this.SelectNextControl(this.ActiveControl, true, true, true, true);
原来一直是为每个文本框的KeyPress增加:
if(e.KeyChar = 'r') SendKeys.Send("{TAB}");
最近想想,其实有更简单的方法,把Form的KeyPreView设为true,然后在Form的KeyPress中增加下列代码即可:
if (e.KeyChar == 'r')
this.SelectNextControl(this.ActiveControl, true, true, true, true);
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/54654/viewspace-425471/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/54654/viewspace-425471/