六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 25|回复: 0

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

[复制链接]

升级  61.3%

726

主题

726

主题

726

主题

探花

Rank: 6Rank: 6

积分
2226
 楼主| 发表于 2013-1-27 05:13:08 | 显示全部楼层 |阅读模式
感谢小板儿砖小利
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
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表