In my codes the problem i encounter it wont delete textboxes dynamically.
> int count = 0;
>
> //I have a Code Which will Create a Textbox During Runtime.
> private void addbox_Click(object sender, EventArgs e) // button to create dynamic textbox
> {
>
> count++;
> for (int i = 0; i < count; i++)
> {
> TextBox textadd = new TextBox();
> this.Controls.Add(textadd);
> textadd.Location = new System.Drawing.Point(Left, Top);
> textadd.Name = "btnUserInput";
> textadd.Size = new Size(376, 50);
> textadd.BringToFront();
>
>
> TextBox textadd1 = new TextBox();
> this.Controls.Add(textadd1);
> textadd1.Location = new System.Drawing.Point(619, Top);
> textadd1.Name = "btnUserInput";
> textadd1.Size = new System.Drawing.Size(228, 38);
> textadd1.BringToFront();
>
> }
>
> }
>
>
>
> private void textdelete_Click(object sender, EventArgs e)
> {
> int count = this.panel1.Controls.Count; // button to delete textboxes
> if (count > 0)
> {
> this.panel1.Controls[count - 1].Dispose();
> }
>
>
> }