程序:Do You Love Me ?
说明:就是鼠标移动到“不爱”按钮上按钮就会移动到其他地方
代码:
28 //鼠标进入控件表面的事件MouseEnter 29 //this.ClientSize.Width 窗体宽度 30 //button2.Width 按钮的宽度 31 //设置按钮的位置: button2.Location=new Point(x,y);x,y坐标 32 private void button2_MouseEnter(object sender, EventArgs e) 33 { 34 int x = this.ClientSize.Width - button2.Width; 35 int y = this.ClientSize.Height - button2.Height; 36 Random r = new Random(); 37 button2.Location=new Point(r.Next(0,x+1),r.Next(0,y+1)); 38 }
时间: 2024-11-19 00:17:45