c# winform 不得不爱,(控件窗口尺寸)

private void button2_MouseEnter(object sender, EventArgs e) //mouseENter方法,鼠标进入图形部分时
{
//根据客户端尺寸变更长短
int x = this.ClientSize.Width - button2.ClientSize.Width;
int y = this.ClientSize.Height - button2.ClientSize.Height;
//随机数 next()
Random rom = new Random();
//point为结构
button2.Location = new Point(rom.Next(0,x),rom.Next(0,y));
}

浙公网安备 33010602011771号