child form
How to use a panel as mdi parent to load another form within it
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Manaswinee MohapatraPosted Jul 16, 2007, 4:52 AM
System.Windows.Forms.Form CurrentForm; // defined in the class declaration
private void menuItem1_Click(object sender, System.EventArgs e)
{
Form2 FormToLoad;
FormToLoad = new Form2();
LoadForm(FormToLoad);
}
private void menuItem2_Click(object sender, System.EventArgs e)
{
Form3 FormToLoad;
FormToLoad = new Form3();
LoadForm(FormToLoad);
}
private void LoadForm(Form TheForm)
{
Point pp;
TheForm.MdiParent = this;
TheForm.Dock = System.Windows.Forms.DockStyle.Fill;
pp = this.splitter1.Location;
pp.X += this.splitter1.Width;
TheForm.Location = pp;
TheForm.Parent = this.panel1;
TheForm.Width = this.panel1.Width;
TheForm.Height = this.panel1.Height;
TheForm.MaximizeBox = false;
TheForm.MinimizeBox = false;
if (CurrentForm != null)
CurrentForm.Close();
CurrentForm = TheForm;
TheForm.Show();
}
I think the above code will help you.