Code for creating text fields ...
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); }
Code to delete all text fields.
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"); } }
When I click btnAddIncrement, I get the following as expected ... 
But when I press reset, it skips every second text field. See below...

I donβt know what is going on here, but itβs the same thing no matter how you add text fields. He always skips every second box.
c # winforms
user3755946
source share