I am using windows form Application, all that i have knew have tried, but cannot access Child form Control of a Parent form.
Code that i have tried till now:
this.ParentForm.Controls["PanelContainer"].Visible = false;
and
this.MdiParent.Controls["pnlContainer"].Visible = false;
and
Form myform = btnLogin.FindForm();
myform.Parent.Controls["PanelContainer"].Visible = false;
I have tried setting a public property for the Panel Control:
public Panel PanelContainer
{
set { pnlContainer = value; }
get { return pnlContainer; }
}
but all i am getting an exception, "Onject Reference not set to an instance of an object"
EDIT1: Here is the snapshot of My Form:
EDIT2: this is how I am adding the form in ContainerPanel
var login = new Login();
login.TopLevel = false;
login.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
PanelContainer.Controls.Add(login);
login.Show();