c#登录界面,输入帐号密码按回车键直接登录

//输入账号        
private void tbUser_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyValue == 13)
            {
                MessageBox.Show("请输入密码", "提示");
                this.tbUser.Clear();
            }
        }

        //输入密码
        private void tbPwd_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyValue == 13)
            {
                this.btnOK.Focus();
                btnOK_Click(sender, e);
            }
        }

        //登录按钮
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (true)
            {
                this.Hide();
                FrmSelect f3 = new FrmSelect();
                f3.Show(); 
            }
            else
            {
                MessageBox.Show("帐号密码错误", "提示");
                tbUser.Clear();
                tbPwd.Clear();
                this.tbUser.Focus();
            }
        }

你可能感兴趣的:(原创)