日期:2014-05-17  浏览次数:20787 次

PictureBox随机改变
PictureBox随机改变位置,不要超出窗体,
  PBox.Location = new System.Drawing.Point();  
怎么随机X,Y


------解决方案--------------------
Random my=new Random();
x=my.nextnew(0,windowx.width);
y=my.nextnew(0,windowx.heigth);
------解决方案--------------------
Random rd = new Random(DateTime.Now.Second);
int x = 0, y = 0;
x = rd.Next(0, this.Width);
y = rd.Next(0, this.Height);
Point p=new Point(x,y);
PBox.Location = p;