Windows forms tips continued ... Do not feel bad if you have not gotten it yet ... it requires a PHd in Dock and Anchor layout to understand. Fortunately the Whidbey release addresses this, but in the meantime here's how to work with the old.First stop: understanding dock and anchor layout.Lets add two controls to the form:. TreeView, a ListView The treeview will dock to the left side of the form, the list view will fill the rest of the space.
TreeView.dock = DockStyle.Left; listview.dock = DockStyle.Fill;
If you added the controls to the control collection like SO:
This.Controls.addRange (New Control "; TreeView, ListView};
You'd notice that the list view would completely fill the space, and that the treeview would be sitting above it Not what we wanted at all This is because the "Z-Order" -.. That is - the way the controls pile up on one another in the Z axis -.. is controlled by the order of the controls in the controls collection The last control in the collection is on top, the first control is on the bottom When the dock layout manager came through and set the sizes and locations of everyone, it started with the controls at the back and moved forward So it said listView -. fill up the size of the form, treeview, set your height to be the height of the form and stay over here to the left. What We real want is for the listview to fill the remaining space after the treeview has already laid itself out.
THIS.CONTROLS.Addrange (new control "{listview, treeview};
Now we've got everyone where they want to be -. Its time to add the splitter Again the splitter wants to be Dock = Left, and wants to be added AFTER the treeview has been added but before the listView fills up the remaining space.
this.Controls.AddRange (new Control [] {listView, splitter, treeView}); There are handy functions on control (which also appear in the designer - right click):. BringToFront and SendToBack - as well as Controls.SetChildIndex These all shift around the ordering of the Controls collection. If you get stuck in with the wrong z-order in the designer, these are quite handy. Whidbey also has some pretty snazzy features when it comes to looking at the entire tree of controls at once. There you have it - you now since you're now qualified for a phd - congrats! ;-)