01windows Forms program learning, 01windows Forms Program
1 2 3 static user name and password logon Exercise 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 ("Logon successful"); 13} 14 else15 {16 MessageBox. show ("Incorrect username or password"); 17} 18 19} 20 21 22 23 form close message tip Exercise 24 25 private void Form2_FormClosing (object sender , FormClosingEventArgs e) 26 {27 DialogResult re = MessageBox. Show ("are you sure you want to disable it? "," Message ", MessageBoxButtons. yesNo); // whether to disable the message prompt box 28 if (re = DialogResult. no) 29 {30 e. cancel = true; // close 31} 32 else33 {34 e. cancel = false; // do not close 35} 36} 37 38