heisetoufa 发表于 2013-1-27 05:13:08

c# winform 循环遍历界面上的所有控件,foreach,Controls,AllowDrop

感谢小板儿砖和小利
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;    }   } 
黑色头发  http://heisetoufa.iteye.com
页: [1]
查看完整版本: c# winform 循环遍历界面上的所有控件,foreach,Controls,AllowDrop