【发布时间】:2017-01-12 07:13:36
【问题描述】:
我正在尝试制作 Windows 应用程序来计算 GPA 。用户可以输入主题的数量,应用程序会创建与主题数量一样多的文本框。但我无法从文本框中获取值。这是我正在尝试的代码
private void button1_Click(object sender, EventArgs e)
{
for (int i = 0; i < int.Parse(textBox1.Text); i++)
{
Label supjects = new Label();
supjects.Text = "supject " + (i+1) ;
supjects.Location = new System.Drawing.Point(60, 70+i*41);
supjects.Name = "supject" + i;
this.Controls.Add(supjects);
TextBox fullMark = new TextBox();
fullMark.Location = new System.Drawing.Point(162, 70 + i * 41);
fullMark.Size=new System.Drawing.Size(57, 24);
fullMark.Name = "fullMark" + i;
this.Controls.Add(fullMark);
TextBox yourMark = new TextBox();
yourMark.Location = new System.Drawing.Point(272, 70 + i * 41);
yourMark.Size = new System.Drawing.Size(57, 24);
yourMark.Name = "yourMark" + i;
this.Controls.Add(yourMark);
}
【问题讨论】:
-
谢谢,但你能把代码发给我吗? @L.B
标签: c# winforms dynamic textbox