I am a begginer. I am creating a winform app, in that I have a Mainform(F1) and several differnt forms which are going to display in a panel(p1) of F1, from these one (F2) is open in load event of F1, there is also ToolStripMenuItem_Click to open form (F3) in same panel.
Now I placed a Close button in F3 to close this form and open a new form F1 again. to make my Mainfrom original appearence.
now as I click on close button F3 gets close and error shows 'panel1 was null'
pls help and don't mind my language and writing skills.
p1=panel_left_main (which is in Mainform) F2=Template
<//form3//>
private void btn_close_Click(object sender, EventArgs e)
{
this.Close();
th = new Thread(opennewform);
th.SetApartmentState(ApartmentState.STA);
th.Start();
}
private void opennewform()
{
Template tpt = new Template();
tpt.TopLevel = false;
tpt.Dock = DockStyle.Fill;
tpt.TopMost= true;
panel_left_main.Controls.Add(tpt);//< here error is comming //
tpt.Show();
}