Click here to Skip to main content
15,884,629 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have a form mdi parent type and in this form have a treeview menu. treeview menu take some space on this form. when i click on a node of treeview a new form open namely(master form). when i maximize the opened form (master form) then some portion goes behind the treeview.i want to maximize that form leave the treeview menu portion.
Posted

1 solution

What you are seeing is the standard behaviour and if you want the maximised child forms to respect the positioning of your treeview then it should be DOCKED not anchored. You will probably want the treeview against either the left or right edges of the form so use DockStyle.Left or DockStyle.Right.

Alan.
 
Share this answer
 
Comments
johannesnestler 29-Apr-14 8:49am    
no, this won't work with the MdiClient
Alan N 29-Apr-14 9:34am    
I tested before posting so I am going to disagree. The main form's control collection (MFCC) initially has one member, the fully docked MdiClient control which is the container for the mdi children. If more controls are added to the MFCC, then they must also be docked otherwise the MdiClient will continue to occupy all of the client area of the main form and maximised mdi children will be appear to be "too big".
johannesnestler 30-Apr-14 5:01am    
For Readers:
I was wrong, it works as Alan said, just reset the Z-Order of the MdiClient after Docking other (nonfFilling of course) controls. A reference to the MdiClient can be obtained from the MdiContainer-Form like this: MdiClient mdiClient = formMDI.Controls.OfType<mdiclient>().First();
johannesnestler 29-Apr-14 9:46am    
Hi Alan,

I don't know what you tested, but just Setting the dockstyle on treeview won't help to solve op's Problem. Maybe give it a try. I'd guess you tested with code similar to this:
static void Main()
{
Form formMDI = new Form
{
Text = "Parent",
IsMdiContainer = true
};

TreeView treeview = new TreeView
{
Dock = DockStyle.Left,
Parent = formMDI
};

TreeNode nodeNewChildForm = new TreeNode
{
Text = "Dummy"
};

treeview.Nodes.Add(nodeNewChildForm);
treeview.NodeMouseDoubleClick += (object sender, TreeNodeMouseClickEventArgs e) =>
{
Form formChild = new Form
{
Text = "Child" + formMDI.MdiChildren.Length,
Parent = formMDI
};

formChild.Show();
};

Application.Run(formMDI);
}
Now try to move the child form "behind" the treeview - it works - same with maximize - this is OP's Problem (what I understand)

Greetings Johannes
Alan N 29-Apr-14 12:18pm    
From the indentation of these comments it looks as if I may have replied to myself. Take a look at what I said in response to your latest.

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