110,571
社区成员
发帖
与我相关
我的任务
分享
id = rand.Next(0,this._bitMap.Length-1); //你先取了个随机的ID值
foreach(Control c in this.Controls) //然后开始遍历所有的控件! 问题!你把50个控件都显示一样的东西干嘛?这里你的ID又没有改变,
{
if(c is PictureBox) //这里,如果是picturebos则改他的图
{
((PictureBox)c).Image = (Image)this._bitMap[id];
}
if (c is Label) //同时,如果上面成立,这里还要判断干嘛? 应改为else if
{
((Label)c).Text = users.Rows[id]["Name"] as string;
}
}