winform? webform?for(int i=0; i < 10; i++)
{
  TextBox tb = new TextBox();
  ...
  this.Controls.Add(tb); //for webform, you need to do Form1.Controls.Add(tb);
}

解决方案 »

  1.   

    class YourForm : Form
    {
       private System.Windows.Forms.TextBox[] textboxes;....
    int n = 10;
    int nLeft = 10;
    int nTop = 10;
    int nHeight = 30;
    textboxes = new TextBox[n];
    for (int i=0; i < n; i++)
    {
    textboxes[i] = new TextBox();
    textboxes[i].Name = "txt" + i.ToString();
    textboxes[i].Location = new System.Drawing.Point(nLeft, i*nHeight + nTop);
    this.Controls.Add(textboxes[i]);
    }
      

  2.   

    tb[i].Location = new System.Drawing.Point(nLeft, i*nHeight + nTop);
    这句报的错误:
    “其他信息: 索引超出了数组界限。”
      

  3.   

    哦,I see!是我的循环那超出数组的范围了。谢谢。