0
Reply

Trying to reset the GUI

Kriti

Kriti

Jun 3 2010 6:17 AM
2.7k

Hey I am trying to reset everything in  my GUI page on clicking clear button
I have dynamically created textboxes and checkboxes.
On clicking Add button,textbox and checkbox gets created and Addbutton and RemoveButton shiftes down to give space to newly created textbox .
On checking the checkbox,the particular textbox removed.
So now I want that the clear botton should clear everything and also the add and remove button should be shifted to original position
here is my code
private void btnClear_Click(object sender, EventArgs e)
{
foreach (Control c in groupBox1.Controls)
{
if ((c.GetType().Name == "TextBox") || (c.GetType().Name == "CheckBox"))
{
groupBox1.Controls.Remove(c);
}
}
foreach (Control c in groupBox3.Controls)
{
if ((c.GetType().Name == "TextBox") || (c.GetType().Name == "CheckBox"))
{
groupBox3.Controls.Remove(c);
}
}
}
but the problem is that..Everything doesnot get cleared up at one click of clear button...I have to press clear button manytimes to clear everything from two group boxes.