怎么实现啊,要求用循环语句写,要是用手拖的话就不麻烦大家了

解决方案 »

  1.   

    for(int i = 0  ; i < 5;i++)
    {
        for(int j = 0 ; j < 10;j++)
        {
            TextBox txt = new TextBox();
            txt.Name = "txt" + i + j;
            txt.Location = ......
            this.Controls.Add(txt);
        }
    }大致这样吧
      

  2.   

    for()
    {
    textBox = new System.Windows.Forms.TextBox();
    textBox.location = new point..
    ....
    this.controls.add(textBox );
    }
      

  3.   

    参考如下代码:
    for (int i = 0; i < 5; i++)
    {
        for (int j = 0; j < 10; j++)
        {
            TextBox textBox = new TextBox();
            textBox.Name = string.Format("textBox{0}_{1}", i, j);
            textBox.Width = 40;
            textBox.Location = new Point(j * (textBox.Width + 3), i * (textBox.Height + 3));
            Controls.Add(textBox);
        }
    }
      

  4.   

     private void Form1_Load(object sender, EventArgs e)
            {
                for (int i = 0; i < 50; i++)
                {
                    TextBox txtBox = new TextBox();
                    txtBox.Name = "TextBox" + i.ToString();
                    txtBox.Width = 50;
                    txtBox.Location = new Point(100+(i%5)*50,100+(i/5)*30);
                    this.Controls.Add(txtBox);
                }
            }
      

  5.   

    TextBox[] txts=new TextBox[50];
    int x=20;
    int y=20;
    int i=0;
    foreach (TextBox txt in txts)
    {
      if(i==10)
       {
         x=20;
         y+=20;//控件的垂直间隔,
       }
       txt=new TextBox();
       txt.Location(x,y);   
       x+=20;//控件之间水平的间隔自己放十个先看看间隔,再把他们删除
       i++;
       this.Controls.Add(txt);
    }
      

  6.   

    位置呢,
    ---------》
    位置你自己定啊
    我又没看见你的Form
    我怎么知道你想放什么位置for(int i = 0  ; i < 5;i++) 

        for(int j = 0 ; j < 10;j++) 
        { 
            TextBox txt = new TextBox(); 
            txt.Name = "txt" + i + j; 
            txt.Location = ...... 
            //这只是简单的根据位置算一下Location,不会这也不会吧~~~~~~~
            this.Controls.Add(txt); 
        } 
    } 横坐标: 10 + j*20
    纵坐标:  10 + i*20
    类似这种,你自己根据需要调调就可以了 
      

  7.   

     txt.Location=new Point(x,y);
      

  8.   

    我是刚学的,只学了理论所以有些类是不知道怎么用的,比如LOCATION,总结了一下jinjazz 算是比较经典的,同时也谢谢大家的各种算法,我会向大家学习的