Docking Problems RRS feed

  • Question

  • I have a form with a menu and a toolbar, a splitter panel and other controls in the splitter.  If I dock the splitter, it slides up under the toolbar and the menu bar. I put the menu and toolbar into a panel and docked that panel to the top. then dock the splitter to fill or to the left. Fill puts the splitter under the top panel and left moves the top panel to the side.  Is there an attribute I am missing to prevent this?  Suggestions?
    Thursday, November 17, 2005 12:25 AM


  • Right-click on the Splitter panel and click Bring to Front.

    Thursday, November 17, 2005 12:58 AM

All replies

  • Right-click on the Splitter panel and click Bring to Front.

    Thursday, November 17, 2005 12:58 AM
  • I used to have all kinds of docking troubles like this. The key is to understand that the docking precedence is determined by the order that controls are added to the Form's controls collection. If you look at the code produced by VS you will see the order the controls are added. This is what the code SHOULD look like to get the docking you want:




    This arrangement means that the docking precedence goes: menu, toolstrip, splitcontainer. This will cause the splitcontainer to fill the remaining space under the other controls.

    And as the other poster stated, you can fix this ordering by simply clicking on the control in question and select "bring to top". This changes the ordering of the controls.

    Good luck.

    Thursday, November 17, 2005 1:18 AM
  • Thanks
    I did the "Bring to Front" in code.  Works great.
    Thursday, November 17, 2005 1:25 AM
  • Good info, the previous post did fix the problem, however this looks like a more permanent solution.
    Thursday, November 17, 2005 1:26 AM
  • Bring to Front actually controls the order the controls are added to the collection. So Bring to Front is the easy way to do within the user interface, the other way is the manual way.

    Thursday, November 17, 2005 2:14 AM
  • Yes, I didn't mean for you to edit the code that VS creates. I just wanted you to know the reasoning behind the strange docking behavior. The docking order is determined by the z-order which is determined (by default) by the order in which controls are added to the Form's controls collection. Using "bring to front" is better than manually editing the code that VS creates. However, if you don't understand WHY "bring to front" fixes the issue then you will likely always struggle with getting your docking to work right. Once this was explained to me I haven't struggled with docking since.

    It's a very easy (and critical) piece of information to understand. I just don't know why Microsoft couldn't have made this clearer in the documentation.
    Thursday, November 17, 2005 3:29 AM
  • BlazingFox,

    You're right. I remember struggling with this very thing. When I first encountered this, I went looking for a ZIndex/ZOrder property (which of course doesn't exist) and only later realized that it a control's position in the Controls collection that determines the z-order.

    Thursday, November 17, 2005 5:21 AM
  • One last post ....
    Right clicking on a splitter is an interesting chore.  The only spot that works is one of the corner spots.  Everywhere else gets one of the interior panels. Or one of the components added to the panels.

    As an exercise I created a grapic utility for moving files and with this problem solved all is well.

    Thanks again.
    Thursday, November 17, 2005 3:36 PM
  • You don't actually have to click on the splitter. You can actually right-click on one of the panels and select Send to Back.
    Thursday, November 17, 2005 8:28 PM
  • In the property window, there's a dropdown of the controls in your form, you can select the splitter and then it's much more easyer to right click it.. or some keyboard have a "show context menu" button.
    Thursday, November 17, 2005 9:39 PM
  • I know I'm late on this post (new to this section of the forum), but even another way is to open the "document outline" (found under the view menu in "other windows".  This thing is slick!  It shows you a tree view of the heirarchy of all your controls.

    From this view, you can not only drag them around to change their order, but I find it a much easier place to select items like SplitContainers when I want to edit their properites.

    Jim Tomasko


    Wednesday, March 7, 2007 4:30 AM