Basically i got a form with a panel inside of it 2 buttons one called newClient , once the user clicks on it the Click_event kicks in (check the code ) !
I have tried to dispose cntrols inside of the panel but still nothing !
private void newClient_Click(object sender, EventArgs e)
{
MainPanel.Dispose();
this.Height += 300;
this.CenterToScreen();
string[] txtBoxNames = new string[] { "fullName", "cinRef", "mainAddr", "phoneNbr","gender","birthDate" };
try
{
for (int i = 0; i < 4; i++)
{
TextBox tb = new TextBox();
tb.Name = txtBoxNames[i];
tb.Location = new Point(20, 150);
this.Controls.Add(tb);
}
}
catch (Exception ex )
{
MessageBox.Show(ex.Message);
}
}
In brief, what i'm trying to achieve here is to add some dynamic Controls to the form !