c# winform用“回车”键代替“Tab”键是提高用户体验

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/lilin8905/article/details/43198091
//首先将窗体的 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);
    }
}

猜你喜欢

转载自blog.csdn.net/lilin8905/article/details/43198091
今日推荐