我的Form1里有Play1 ~ Play20 与 Stop1 ~ Stop20 的Button
我想要点到 Play1 的时候 Play1~20.Visible = false;
Stop1.Visible = true;
Stop2~20.Visible = false;怎样实现呢?我无法用 Play(变数).Visible = false 这样的方式!
以前有写过类似的但是忘记了~~求指导~
            

解决方案 »

  1.   

    这个主要是用javascript实现吧...
      

  2.   

    哦,对不起,看错了,是winform的
      

  3.   

    FindControl("Play"+变数).Visible = 
    FindControl("Play"+变数).Visible = false;
      

  4.   

    foreach(Control ctl in this.Controls)
    {
       Button btn =ctl as Button;
       if(btn !=null)
        {
           btn.Visible = false;
           //
           //
        }
    }
      

  5.   

    对对对~~以前好像是用 FindControl() 我试试看!
      

  6.   

    遍历Controls
    foreach(Control ctrl in this.Controls)
    {
       通过((Button)ctrl).Text获得名称,下标进行显示或隐藏
    }
    或将两组按钮放入泛型列表,进行下标进行控制操作
      

  7.   


    foreach(Control   ctl   in   this.panel.Controls) 

        for(int i=1;i<=20;i++)
        {
           if(ctl.Name== "Stop"+i   ) 
           { 
                ctl.Visible = false; 
           } 
        }
    }
    这样试试看
      

  8.   

    foreach(Control ctl in this.Controls)
    {
      Button btn =ctl as Button;
      if(btn !=null)
      

  9.   

    这样不是Form1所有的Button都会被改到吗?这Form1 还有其他的Button喔!
      

  10.   


    里面可以判断的呀。if(ctl.Name== "Stop"+i   ) 。
      

  11.   

    原来以前是写ASP.NET 所以才有FindControl()这方法,
    看样子子有用foreach(Control ctl in this.Controls)的方式解决了~