【发布时间】:2016-01-29 11:50:28
【问题描述】:
创建文本框的代码...
private void btnAddIncrement_Click(object sender, EventArgs e)
{
SmartTextBox dynamictextbox = new SmartTextBox();
dynamictextbox.BackColor = Color.Bisque;
dynamictextbox.Width = this.tbWidth;
dynamictextbox.Left = (sender as Button).Right + this.lastLeft;
dynamictextbox.K = "Test";
this.lastLeft = this.lastLeft + this.tbWidth;
dynamictextbox.Top = btnAddStart.Top;
this.Controls.Add(dynamictextbox);
}
删除所有文本框的代码。
foreach (Control c in this.Controls)
{
if (c.GetType() == typeof(BnBCalculator.SmartTextBox))
{
count++;
//MessageBox.Show((c as SmartTextBox).K.ToString());
c.Dispose();
}
// else { MessageBox.Show("not txtbox"); }
}
当我单击 btnAddIncrement 时,我按预期得到以下内容...
但是当我点击重置时,它会错过第二个文本框。见下文...
不知道这里发生了什么,但无论我添加多少文本框都是一样的。它总是错过第二个盒子。
【问题讨论】: