02 button exercises, 02button exercises
1 2 3 private void button#click (object sender, EventArgs e) 4 {5 MessageBox. Show ("I like you too! "); 6 // if (this. button1.Text = "like") 7 // {8 // button2.Visible = false; 9 //} 10 11} 12 private void button2_Click (object sender, EventArgs e) 13 {14 MessageBox. show ("I still don't like you! "); 15 // if (this. button2.Text = "dislike") 16 // {17 // button1.Visible = false; 18 //} 19 20 21} 22 23 private void button2_MouseMove (object sender, MouseEventArgs e) 24 {25 // The Button2 cannot move the mouse to 26 Random suiJi = new Random (); 27 int x = suiJi. next (0, this. size. width-this.button2.Size.Width); 28 int y = suiJi. next (0, this. clientSize. height-this.button2.Size.Height); 29 30 Point p = new Point (x, y); 31 button2.Locat Ion = p; 32 33} 34 35 private void Form1_Load (object sender, EventArgs e) 36 {37 MessageBox. Show ("do a test !! "); // Messagebox is a type that will be followed. 38 39} 40 41 private void Form1_FormClosing (object sender, FormClosingEventArgs e) 42 {43 // simple syntax of the form close event 44 DialogResult re = MessageBox. show ("are you sure you want to close", "Ask", MessageBoxButtons. yesNo, MessageBoxIcon. question); 45 if (re = DialogResult. no) 46 {47 e. cancel = true; 48} 49}