G
Guest
we have a need to create independent forms and then load them to an area (panel) in the main window depending on the user action. Like the main window is layed out like : tree control, splitter bar, panel
then we load the independent forms into panel1 (unload what was there)..
The following is the code I've come up with.... am I on the right/proper track for this or is there a better way
System.Windows.Forms.Form CurrentForm; // defined in the class declaratio
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()
then we load the independent forms into panel1 (unload what was there)..
The following is the code I've come up with.... am I on the right/proper track for this or is there a better way
System.Windows.Forms.Form CurrentForm; // defined in the class declaratio
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()