打开visual 2010,新建窗体,既然是登录窗口,那么就不让它出现最大化、最小化以及拖拉大小功能(上一节已经提到过怎么设置大小),如图所示,甚至窗体的Text属性值为“登录窗口”,大小随意。
创建窗体之后就开始界面详细的组件布局了,主要是在左边拖拉控件,然后放到窗体中去,定义属性值。这些都比较简单。
到了代码响应阶段,双击登录按钮,进入代码视图: private void button1_Click(object sender, EventArgs e) { String name = this.textBox1.Text; // 获取里面的值 String password = this.textBox1.Text; if (name.Equals("admin") && password.Equals("admin")) // 判断账号密码是否等于admin { MessageBox.Show("登录成功"); } else { MessageBox.Show("登录失败!"); } }