感谢小板儿砖和小利
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;
}
}
--------------------------------------------------------------------------------------------------------------------------
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#代码遍历窗体(Form)及其groupBox上的所有控件,并将PictureBox控件设置为允许拖放操作。此功能对于实现更加灵活的用户交互具有重要作用。

3770

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



