用“回车”键代替“Tab”键

编辑器加载中...

//首先将窗体的 keypreview 的属性设为 true
 
private void 窗体_KeyPress(object sender, KeyPressEventArgs e)
{
    if ( e.KeyChar == (char)13 )
    {
        this.SelectNextControl(this.ActiveControl, true, true, false, true);
    }
}
 
//或
 
private void Form1_KeyDown(object sender, KeyEventArgs e)
{
    if ( e.KeyData == Keys.Enter )
    {
        this.SelectNextControl(this.ActiveControl, true, true, false, true);
    }
}
posted @ 2012-03-17 00:02  跟着阿笨一起玩.NET  阅读(589)  评论(2编辑  收藏  举报