Kriti

Kriti

  • NA
  • 60
  • 0

handle dynamic insertion and deletion of textboxes depending upon the checkboxes checked.

May 28 2010 5:13 AM


In my GUI page,I have
1.AddButton  //It creates textbox and checkbox (beside textbox).
2.RemoveButton //It deletes the textboxes(and the data) for which the checkboxes are checked
3.Updatebuton //Finally it updates total no. of textboxes(its content) in the database.

//Code for dynamic creation of textbox and chechbox when Add button is clicked.
public int topPosition = 30;
private void btnAdd_Click(object sender, EventArgs e)
        {
           
            TextBox newtxt = new TextBox();
            CheckBox newchkbox = new CheckBox();
            newchkbox.Location = new System.Drawing.Point(230, 72 + topPosition);
            newtxt.Location = new System.Drawing.Point(27, 72 + topPosition);         
            newtxt.Size = new System.Drawing.Size(187, 20);
            this.btnAdd.Location = new System.Drawing.Point(27, 109 + topPosition);
            this.btnRem.Location = new System.Drawing.Point(113, 109 + topPosition);
            groupBox1.Controls.Add(newtxt);
            groupBox1.Controls.Add(newchkbox);
            topPosition += 30;
           
        }
How Could I write a code which deletes the textboxes for which checkboxes are clicked because all are dynamically created.
And finally how to update in the database getting the total number of textboxes and its data.
And i am using System.windows.Forms which doesnt allow to use Id related to each textbox or checkbox.

Answers (1)