我有以下代码在每个按钮单击上创建一个文本框:
private void AddNewTimer_Click(object sender, EventArgs e)
{
int timerCount = 0;
int boxY = 0;
if (timerCount <= 6)
{
timerCount++;
TextBox txt = new TextBox();
txt.ID = "timer" + timerCount++;
txt.Text = Convert.ToString(timerCount);
txt.Name = Convert.ToString(timerCount);
txt.Width = 63;
txt.Location = new Point(0, boxY);
TimerContainer.Controls.Add(txt);
boxY = boxY + 25;
}
}
Run Code Online (Sandbox Code Playgroud)
txt.ID = timerCount++;给我'TextBox' does not contain a definition for 'ID',虽然在回答说明这个问题,在这个页面.