Click here to Skip to main content
15,886,074 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have Tree View Control on Left side in a Windows Mdi Parent form . How can i Hide and Show the Tree view control.(eg: Visual Studio TOOL BOX Method). Please Help Me.
Posted
Updated 15-Sep-14 21:17pm
v2

1 solution

imho, Windows MDI application structure is kind of a "fossil" these days, and I would encourage you to, instead, consider writing an application with multiple independent Forms. But, the fact remains that a lot of people are still using MDI, and many students are being assigned projects requiring them to write MDI applications.

In the Windows MDI architecture, you should not add Controls to the MDIParentForm directly; they will obscure (be shown in front of) all MDIChild Windows their bounding-boxes intersect with.

Under-the-hood the MdiParentForm hosts another Window of a special Type: "System.Windows.Forms.MdiClient." When you make a new instance of a Form the MDIChild of an MDIParentForm, the Form is added to the MdiClient's ControlCollection.

Consider this: create one MDIChildForm to hold the TreeView, and use its Dock, or Anchor, Properties to position it where you want it to be.

If you defined two Forms, 'ChildForm1, and 'ChildForm2, and Form 'ChildForm1 had a TreeView docked inside it: your MDIParentForm Load event might look like this:
ChildForm1 child1 = new ChildForm1();
ChildForm2 child2 = new ChildForm2();

private void MdiParentForm_Load(object sender, System.EventArgs e)
{
    // hide the close box ?
    child1.ControlBox = false;
    // borderless, without Caption ?
    child1.FormBorderStyle = FormBorderStyle.FixedToolWindow;
    child1.Text = "";

    child1.MdiParent = this;
    child1.Dock = DockStyle.Left;

    child2.MdiParent = this;
    child2.Dock = DockStyle.Right;

    child1.Show();
    child2.Show();     
}
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900