this.groupBox1.Controls.Add(pb1);
this.groupBox1.Controls.Add(pb2);
this.groupBox1.Controls.Add(pb3);
this.groupBox1.Controls.Add(pb4);
this.groupBox1.Controls.Add(pb5);
this.groupBox1.Controls.Add(pb6);
this.groupBox1.Controls.Add(pb7);
this.groupBox1.Controls.Add(pb8);
this.groupBox1.Controls.Add(pb9);
this.groupBox1.Controls.Add(pb10);
foreach (Control item in this.groupBox1.Controls)
{
if (item is PictureBox)
{
PictureBox pb = item as PictureBox;
pb.Image = null;
}
}
本文介绍了一种方法,用于在C#应用程序中遍历groupBox内的所有PictureBox控件并清除其显示的图片。通过类型检查确保只处理PictureBox,并将图片属性设置为null来实现这一目的。
3779

被折叠的 条评论
为什么被折叠?



