foreach (System.Windows.Forms.Control control in this.groupBox2.Controls)//遍历groupBox2上的所有控件
{
if (control is System.Windows.Forms.PictureBox)
{
System.Windows.Forms.PictureBox pb = (System.Windows.Forms.PictureBox)control;
pb.AllowDrop = true;
}
if (cl is CheckBox)
{
Label lab = cl as Label;
lab.Enabled = false;//在这里设置
}
}
- foreach (System.Windows.Forms.Control control in this.Controls)//遍历Form上的所有控件
- {
- if (control is System.Windows.Forms.PictureBox)
- {
- System.Windows.Forms.PictureBox pb = (System.Windows.Forms.PictureBox)control;
- pb.AllowDrop = true;
- }
- }
本文介绍了一种在C#中遍历groupBox和整个Form上所有PictureBox控件的方法,并展示了如何设置PictureBox的AllowDrop属性为true,以便实现拖放功能。此操作对于需要处理图像文件的Windows Forms应用程序特别有用。
1190

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



