I'm afraid the fix for this is kind of "ugly," but MDI architecture is kind of "old and in the way now." I'd encourage you, unless you absolutely have to use it, to think of another architecture than MDI.
Perhaps you might consider the ability to set one Form as the 'owner' of other Forms: this will guarantee that these 'owned' Forms will appear at the same level in the z-order when displayed; so they will not be covered over by the 'owner' form. Yep, you give up that custom menu you get with MDI if you go this way, but it's not hard to create on your own.
A control (like your TreeView functioning as menu) on the MDIParent will always appear above any MDIChild Form shown. And, such a control on the MDIParent will also affect the placement of MDI Child Forms:
In your case setting the Left property of any MDIChild Form to #0 will effectively set its left edge to the right border of the TreeView (assuming, as shown here, the TreeView is docked 'Left on the MDIParent Form). But, that still leaves the 'sticky' case of what happens when you maximize an MDI Child Form (assuming you don't want to hide its 'maximize' button).
Here's an idea for a (yes, "ugly") way to work around the issue that the MDI Child Form can "get behind" a control on the MDIParent surface:
First the simple case of the Form being moved by the end-user:
private Form2 f2;
private void Form1_Load(object sender, EventArgs e)
{
treeView1.Dock = DockStyle.Left;
f2 = new Form2();
f2.Move += new EventHandler(f2_Move);
f2.SizeChanged += new EventHandler(f2_SizeChanged);
f2.MdiParent = this;
f2.Show();
}
private void f2_Move(object sender, EventArgs e)
{
if (f2.Left < 0) f2.Left = 0;
}
And, then, the case of a 'resize' which could result from the user choosing to 'Maximize' the MDI Child Form, as well as click-and-drag:
private void f2_SizeChanged(object sender, EventArgs e)
{
if (f2.WindowState == FormWindowState.Maximized)
{
f2.WindowState = FormWindowState.Normal;
f2.Bounds = f2.MdiParent.ClientRectangle;
f2.Height -= 6;
f2.Width -= treeView1.Width + 6;
}
if (f2.Left < 0) f2.Left = 0;
}
good luck, Bill