遍历forms上的所有控件

来源:互联网 发布:大数据的数据量 编辑:程序博客网 时间:2024/05/21 06:27
C#代码 复制代码 收藏代码
  1. foreach (System.Windows.Forms.Control control in this.groupBox2.Controls)//遍历groupBox2上的所有控件  
  2.    {   
  3.     if (control is System.Windows.Forms.PictureBox)   
  4.     {   
  5.      System.Windows.Forms.PictureBox pb = (System.Windows.Forms.PictureBox)control;   
  6.      pb.AllowDrop = true;   
  7.     }   
  8.    }  
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;    }   }

 --------------------------------------------------------------------------------------------------------------------------

C#代码 复制代码 收藏代码
  1. foreach (System.Windows.Forms.Control control in this.Controls)//遍历Form上的所有控件  
  2.    {   
  3.     if (control is System.Windows.Forms.PictureBox)   
  4.     {   
  5.      System.Windows.Forms.PictureBox pb = (System.Windows.Forms.PictureBox)control;   
  6.      pb.AllowDrop = true;   
  7.     }   
  8.    }  
原创粉丝点击