Reticulated Spline
Reticulated Spline

Reputation: 2012

Set vertical dock priority over horizontal with DockPanel Suite

I'm using DockPanel Suite but I've run into an issue due to the relatively sparse documentation.

I have two docked panels: one which docks left and right, called "Side", and one which docks on the bottom, called "Bottom". I would like Side to fill the height of the form, with Bottom filling up the rest.

So what I'm aiming for is this: Side dock fill

But what I have instead is this: Bottom dock fill

When I run the program, I get the second variant, and if I drag Bottom out to float it, then drag it back, it will dock the way I want it to, but I can't achieve this programmatically.

Here's my code:

public Form1()
{
    InitializeComponent();

    SideForm side = new SideForm();
    side.Show(dockPanel, DockState.DockRight);

    BottomForm bottom = new BottomForm();
    bottom.Show(dockPanel, DockState.DockBottom);
}

I've tried changing the order, but that has no effect. I've tried poking around the various properties and methods, but there's not much documentation, so IntelliSense is not much help here.

Update

I've tried bringing the side panel to front and/or sending the bottom panel to back as two people have suggested, but that had no effect. Here's the full code for that:

public Form1()
{
    InitializeComponent();

    SideForm side = new SideForm();
    side.Show(dockPanel, DockState.DockRight);

    BottomForm bottom = new BottomForm();
    bottom.Show(dockPanel, DockState.DockBottom);

    // I've tried enabling these one at a time, and even both at once, no effect
    side.BringToFront();
    bottom.SendToBack();
}

User Lex Li made another suggestion about first creating a document then docking to the bottom of that. That seemed to work, except now there is no in the bottom window, as follows:

No titlebar

Here is the code I used to create this:

doc = new Document();
doc.Show(dockPanel, DockState.Document);

side = new SideForm();
side.Show(dockPanel, DockState.DockRight);

bottom = new BottomForm();
bottom.Show(doc.Pane, DockAlignment.Bottom, 0.3);

I can avoid this by setting the main dockpanel's DocumentStyle property to DockingMdi or DockingWindow, which gives me this:

Tabs

But then those tabs are there, which I don't want; I prefer to use DockingSdi style.

So, I'm trying to programatically achieve docking to the very bottom, like this: Showing the location of the dock... Starting to dock

And finally, the docked window Docked

Upvotes: 2

Views: 2083

Answers (2)

Serge N
Serge N

Reputation: 104

Just for the record: to change docking priority, you need to customize the Z-order of DockWindow's. Place this:

dockPanel.UpdateDockWindowZOrder(DockStyle.Right, true);

between InitializeComponent() and the creation/docking of the child forms.

Upvotes: 4

E-Bat
E-Bat

Reputation: 4892

Have you try with Control.BringToFrom() and\or control.SendToBack()?

SideForm side = new SideForm();
side.Show(dockPanel, DockState.DockRight);

BottomForm bottom = new BottomForm();
bottom.Show(dockPanel, DockState.DockBottom);

side.BringToFrom();

or

bottom.SendToBack();

Upvotes: 0

Related Questions