I need to hide a panel on the Parent Form when a Child Form on an MDI Parent Form closes & show back the panel on the Parent form when the Child Form is closed.
Currently am using SendtoBack() to show the Child Form infront of the Panel which is on the Parent Form , but when i close the Child Form, then the Panel doesn't appears back, even if i use :
BringtoFront()
OR
Panel1.Visible=true
public partial class CHILD : Form
{
private void CHILD_Load(object sender, EventArgs e)
{
this.FormClosed += new FormClosedEventHandler(CHILD_FormClosed);
}
void CHILD_FormClosed(object sender, FormClosedEventArgs e)
{
PARENTForm P = new PARENTForm();
P.panel1.BringToFront();
P.panel1.Visible = true;
}
}
public partial class Form1 : Form
{
private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
CHILD P = new CHILD();
P.Showg();
P.MdiParent = this;
P.BringToFront();
panel1.SendToBack();
panel1.Visible = false;
}
}
THIS ISN'T WORKING....PLEASE HELP..!
You creating new parent form in child form. You need to pass parent form object to child form and then use it to show/hide panel and set panel Modifiers property to public. For example...
Parent form:
public partial class ParentForm : Form
{
public ParentForm()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
panel1.Visible = false;
ChildForm childForm = new ChildForm();
childForm.MdiParent = this;
childForm.Show();
}
}
Child form:
public partial class ChildForm : Form
{
public ChildForm()
{
InitializeComponent();
}
private void Child_FormClosed(object sender, FormClosedEventArgs e)
{
ParentForm parentForm = (ParentForm)this.MdiParent;
parentForm.panel1.Visible = true;
}
}