CheckBox[] checkBoxArray = new CheckBox[lines.Count()];
CheckBox checkBox = new CheckBox();
int yLocation = 25;
int diff = 0;
int i = 0;
foreach(var line in lines)
{
this.checkBox.Text = line;
this.checkBox.Location = new System.Drawing.Point(90, yLocation + diff);
this.checkBox.Size = new System.Drawing.Size(110, 30);
checkBoxArray[i] = checkBox;
i++;
diff = diff + 30;
}
我调试了我的应用程序并且checkBoxArray
(在循环之后)都是一样的。
第二个问题是如何将控件添加到 WinForm?