textBox1.Enabled=true;
textBox2.Enabled=true;
....
textBoxN.Enabled=true;
用for循环怎么写啊

解决方案 »

  1.   

    for(int i=1;i<=N;i++)
    {
      TextBox txt=this.FindControl("textBox"+i.ToString()) as TextBox;
      if(box!=null)
      {
         txt.Text="XXX"
      }
    }
      

  2.   

    是WINFORM吗,找不到FindControl,另外(box!=null)是不是 txt
      

  3.   

    foreach(TextBox box in this.Control)
    {
     box..Enabled=true; 
    }不知道有没有写错,差不多就这样了
      

  4.   


    for(int i=1;i <=N;i++) 

      TextBox txt=this.FindControl("textBox"+i.ToString());
      txt.Enabled=true;
    }
    //上面这种写法的前题是你的页面要有textBox1到textBoxN这些控件。如果没有就要动态生成,比如10个TextBox [] textBox = new TextBox[10];
      

  5.   


    foreach(Control control in this.Controls) 

        if(control is TextBox)
        {
            (control as TextBox).Enabled = true;
        }
    }
      

  6.   

    我是说WINFORM,不是网页,页面上有,但是我在VS2008,智能提示里找不到this.FindControl
      

  7.   

    sorry,winform的话,应该是这样:  for (int i = 1; i <= N; i++)
                {
                    TextBox txt = this.Controls["textBox" + i.ToString()] as TextBox;
                    if (txt != null)
                    {
                        txt.Text = "XXX";
                    }
                }
      

  8.   

    void Find(Control.ControlCollection ctls)
    {
      foreach (Control c in ctls)  
      {  
        if (c is TextBox)  
        {  
          
        }
        else if (c.Controls != null) Find(c.Controls); 
      }  
    }
      

  9.   

    this.Controls["txtbox1"] as TextBox;
      

  10.   


    int N = 3;
    for (int i = 1; i <= N; i++)
    {
        this.Controls["textBox" + i].Enabled = false;
    }