我遍历得到了页面上所有的picturebox,但是我想把有个特殊的picturebox排除,语句应该怎么写,
foreach(Control  control in this .Controls)
{
if(control.GetType () == typeof(PictureBox) && control.Name !=pBx_bjl)
         {
   code.............
         }
}
总不至于这么写吧,

解决方案 »

  1.   

    楼主是闲着没事来散分的吧,
    你看这样写行不?嘎嘎~foreach(Control  control in this .Controls) 

             if(control.GetType () == typeof(PictureBox) ) 
             { 
                   if(control.Name !=pBx_bjl)
                   {
                        code............. 
                   }
             } 

    肯定行!!
      

  2.   

    错,,
    D:\My Documents\Visual Studio Projects\lwj\BJL\Form1.cs(200): 运算符“!=”无法应用于“string”和“System.Windows.Forms.PictureBox”类型的操作数
      

  3.   

    foreach(PictureBox picb in this .Controls) 
    {
        if(picb.Name ==???)
       {
          ……
       }
     } 我经常遍列txtbox就这样哈
      

  4.   

    foreach(Control  control in this .Controls) 

    if(control.GetType () == typeof(PictureBox)) 
            if(control.Name == "pBx_bjl")
                 continue;
             { 
                  code............. 
             } 

      

  5.   


    如果太多太多的picturebox 怎么一一列举啊,
      

  6.   

    知道了,我靠,太低级了,不是人犯的错误!!9楼给了我重要的提示
    应该是control.Name !=[color=#FF00FF]"pBx_bjl"[/color]
      

  7.   

    怎么感觉楼主的命名有类似C或者C++的嫌疑,那个p是代表pointer的意思吗?呵呵