添加新评论

You can create textboxes on runtime and just put them in an array...

If you want to do it in design time, you will have to do some control filtering logic on the whole this.Controls array in order to access only the wanted textboxes. Consider if (currControl is TextBox) if all textboxes in the form are ones you want in the array.

Another option for design time, is putting all wanted textboxes in a panel which will be their parent, and then iterating over the panel's children (controls) and cast them to TextBox.

A runtime solution would be something like:

var arr = new TextBox[10];

for (var i = 0; i < 10; i++)
{
    var tbox = new TextBox();

    // tbox.Text = i.ToString();

    // Other properties sets for tbox

    this.Controls.Add(tbox);
    arr[i] = tbox;
}

添加新评论

受限制的 HTML

  • 允许的HTML标签:<a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id>
  • 自动断行和分段。
  • 网页和电子邮件地址自动转换为链接。