首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

PictureBox随机改变,该怎么处理

2012-10-14 
PictureBox随机改变PictureBox随机改变位置,不要超出窗体,PBox.Location new System.Drawing.Point()怎

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;

热点排行