110,535
社区成员
发帖
与我相关
我的任务
分享
public void BuildUI()
{
TBSet1=new TextBox[CourseNums];
TBSet2 = new TextBox[CourseNums];//数组。CourseNums:用户指定个数
Label currentL = label4;//参照物
TextBox currentTB1=textBox1;//参照物
TextBox currentTB2=textBox2;//参照物
for (int i = 1; i <= CourseNums-1; i++)
{
Label la = new Label();
la.AutoSize = true;
la.Location = new Point(currentL.Location.X,currentL.Location.Y+30);
la.Size = new System.Drawing.Size(71, 12);
la.Text ="第"+(i+1)+"门课程:";
Controls.Add(la);
currentL = la;
//---------------------------------
TextBox tb1 = new TextBox();
tb1.Location = new System.Drawing.Point(89,currentTB1.Location.Y+30);
tb1.Size = new System.Drawing.Size(45, 21);
Controls.Add(tb1);
currentTB1 = tb1;
//------------------------------------
TextBox tb2 = new TextBox();
tb2.Location = new System.Drawing.Point(158, currentTB2.Location.Y + 30);
tb2.Size = new System.Drawing.Size(45, 21);
Controls.Add(tb2);
currentTB2 = tb2;
//------------------------------
TBSet1[0] = textBox1;
TBSet2[0] = textBox2;
TBSet1[i] = tb1;
TBSet2[i] = tb2;
}
}
la.Location = new Point(currentL.Location.X,currentL.Location.Y+30);
[Quote=引用 2 楼 findcaiyzh 的回复:]