01windows窗体程序学习
1 2 3 静态用户名和密码的登录练习 4 5 private void button2_Click(object sender, EventArgs e) 6 { 7 8 textUser.Text = Convert.ToString(textUser.Text); 9 textBox2.Text = textBox2.Text.ToString(); 10 if (textUser.Text == "admin" && textBox2.Text == "111111") 11 { 12 MessageBox.Show("登录成功"); 13 } 14 else 15 { 16 MessageBox.Show("用户名或密码错误"); 17 } 18 19 } 20 21 22 23 窗体关闭消息提示的练习 24 25 private void Form2_FormClosing(object sender, FormClosingEventArgs e) 26 { 27 DialogResult re = MessageBox.Show("确定关闭?","消息",MessageBoxButtons.YesNo);//是否关闭消息提示框 28 if (re == DialogResult.No) 29 { 30 e.Cancel = true; //关闭 31 } 32 else 33 { 34 e.Cancel = false; //不关闭 35 } 36 } 37 38
路漫漫其修远兮 吾将上下而求索