Back to Devexpress

DockingOptions.AllowDockToCenter Property

windowsforms-devexpress-dot-xtrabars-dot-docking-dot-dockingoptions.md

latest5.4 KB
Original Source

DockingOptions.AllowDockToCenter Property

Gets or sets whether or not panels can dock to the middle of the DockManager’s parent container (Form or UserControl). This option has no effect in MDI mode when DocumentManager is not used.

Namespace : DevExpress.XtraBars.Docking

Assembly : DevExpress.XtraBars.v25.2.dll

NuGet Package : DevExpress.Win.Navigation

Declaration

csharp
[DefaultValue(DefaultBoolean.Default)]
[XtraSerializableProperty]
public DefaultBoolean AllowDockToCenter { get; set; }
vb
<DefaultValue(DefaultBoolean.Default)>
<XtraSerializableProperty>
Public Property AllowDockToCenter As DefaultBoolean

Property Value

TypeDefaultDescription
DefaultBooleanDefault

The DefaultBoolean enumerator value that specifies whether dock panels can be docked to the container center. The DefaultBoolean.Default value is equivalent to DefaultBoolean.True.

|

Available values:

NameDescriptionReturn Value
True

The value is true.

|

0

| | False |

The value is false.

|

1

| | Default |

The value is specified by a global option or a higher-level object.

|

2

|

Property Paths

You can access this nested property as listed below:

Object TypePath to AllowDockToCenter
DockManager

.DockingOptions .AllowDockToCenter

|

Remarks

If the AllowDockToCenter option is enabled, both you at design time and your users at runtime can drag a panel into the central docking hint of a parent container.

After the first panel is docked to the container middle, you can dock more panels to the center as tabs, or to this central panel’s sides.

To dock panels to the central area in code, use the DockPanel.DockTo(DockPanel, DockingStyle) method.

csharp
dockManager1.Clear();

DockPanel p1 = new DockPanel() { Text = "Panel 1" };
DockPanel p2 = new DockPanel() { Text = "Panel 2" };
DockPanel p3 = new DockPanel() { Text = "Panel 3" };
DockPanel p4 = new DockPanel() { Text = "Panel 4" };
DockPanel p5 = new DockPanel() { Text = "Panel 5"};
DockPanel p6 = new DockPanel() { Text = "Panel 6"};
DockPanel p7 = new DockPanel() { Text = "Panel 7" };

dockManager1.AddPanel(DockingStyle.Left, p1);
dockManager1.AddPanel(DockingStyle.Top, p2);
dockManager1.AddPanel(DockingStyle.Right, p3);
dockManager1.AddPanel(DockingStyle.Bottom, p4);
dockManager1.AddPanel(DockingStyle.Fill, p5);
dockManager1.AddPanel(DockingStyle.Float, p6);
dockManager1.AddPanel(DockingStyle.Float, p7);

p6.DockTo(p5, DockingStyle.Left);
p7.DockTo(p5, DockingStyle.Fill);
vb
dockManager1.Clear()

Dim p1 As New DockPanel() With {.Text = "Panel 1"}
Dim p2 As New DockPanel() With {.Text = "Panel 2"}
Dim p3 As New DockPanel() With {.Text = "Panel 3"}
Dim p4 As New DockPanel() With {.Text = "Panel 4"}
Dim p5 As New DockPanel() With {.Text = "Panel 5"}
Dim p6 As New DockPanel() With {.Text = "Panel 6"}
Dim p7 As New DockPanel() With {.Text = "Panel 7"}

dockManager1.AddPanel(DockingStyle.Left, p1)
dockManager1.AddPanel(DockingStyle.Top, p2)
dockManager1.AddPanel(DockingStyle.Right, p3)
dockManager1.AddPanel(DockingStyle.Bottom, p4)
dockManager1.AddPanel(DockingStyle.Fill, p5)
dockManager1.AddPanel(DockingStyle.Float, p6)
dockManager1.AddPanel(DockingStyle.Float, p7)

p6.DockTo(p5, DockingStyle.Left)
p7.DockTo(p5, DockingStyle.Fill)

To prevent a specific panel from docking to the container center, handle the DockManager.ShowingDockGuides event and disable the central dock guide.

csharp
private void DockManager1_ShowingDockGuides(object sender, ShowingDockGuidesEventArgs e)
{
    if (e.Panel == p7 && e.TargetPanel == null)
        e.Configuration.Disable(DevExpress.XtraBars.Docking2010.Customization.DockGuide.Center);
}
vb
Private Sub DockManager1_ShowingDockGuides(ByVal sender As Object, ByVal e As ShowingDockGuidesEventArgs)
    If e.Panel = p7 AndAlso e.TargetPanel Is Nothing Then
        e.Configuration.Disable(DevExpress.XtraBars.Docking2010.Customization.DockGuide.Center)
    End If
End Sub

See Also

DockPanelOptions.AllowDockFill

DockingOptions Class

DockingOptions Members

DevExpress.XtraBars.Docking Namespace