首页 > 学院 > 开发设计 > 正文

C#程序登陆界面简单实现

2019-11-06 07:38:13
字体:
来源:转载
供稿:网友

程序界面

using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;namespace LoginTest{ public partial class LoginForm : Form { public LoginForm() { InitializeComponent(); } //输入用户名 PRivate void tbUser_KeyDown(object sender, KeyEventArgs e) { if (e.KeyValue == 13)//回车键,到密码输入框 { //MessageBox.Show("Please input the passWord"); this.tbPassword.Focus(); } } //输入密码 private void tbPassword_KeyDown(object sender, KeyEventArgs e) { if (e.KeyValue == 13)//回车键,到登陆按钮 { this.bLogin.Focus(); this.bLogin_Click(sender,e); } } //登陆 private void bLogin_Click(object sender, EventArgs e) { //用户名root,密码toor,大小写不敏感 if(this.tbUser.Text.ToUpper()=="ROOT") if (this.tbPassword.Text.ToUpper() == "TOOR") { this.Hide();//隐藏 MessageBox.Show("Hello world!");//登陆后…… } else MessageBox.Show("用户名或者密码错误!"); else MessageBox.Show("用户名或者密码错误!"); this.Close();//关闭 } }}
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表