在创建它们之后如何制作它们列表?在表单初始化函数中,您可以执行以下操作:
List<TextBox> myTextboxList = new List<TextBox>();
myTextBoxList.Add(TextBox1);
myTextBoxList.Add(TextBox2);
mytextBoxList.Add(TextBox3);
Run Code Online (Sandbox Code Playgroud)
现在,您可以使用下面的"myTextboxList"进行迭代:
Foreach (TextBox singleItem in myTextboxList) {
// Do something to your textboxes here, for example:
singleItem.Text = "Type in Entry Here";
}
Run Code Online (Sandbox Code Playgroud)