下列代码创建了两个面板。 一个面板被停靠到窗体的左边缘,第二个面板是浮动的。 然后把浮动的面板停靠到第一个面板中,因此而创建了一个 分隔式容器。
然后又新建一个浮动面板。 它被作为一个新项添加到所创建的分隔式容器中的第一个位置上。 在本例中,通过 DockPanel.DockTo 方法来把面板停靠到其他面板中。 但是也可以通过 DockPanel.AddPanel 方法创建一个面板并把它停靠到另一个面板中。
结果显示如下:
C# | ![]() |
---|---|
using DevExpress.XtraBars.Docking; // ... // Create two panels. DockPanel dp1 = dockManager1.AddPanel(DockingStyle.Left); dp1.Text = "Panel 1"; DockPanel dp2 = dockManager1.AddPanel(DockingStyle.Float); dp2.Text = "Panel 2"; // Dock the dp2 panel to the dp1 panel. This will create a split container. dp2.DockTo(dp1); // Create a floating panel. DockPanel dp3 = dockManager1.AddPanel(DockingStyle.Float); dp3.Text = "Panel 3"; // Dock this panel to the split container at the first position. dp3.DockTo(dp1.ParentPanel, 0); |
Visual Basic | ![]() |
---|---|
Imports DevExpress.XtraBars.Docking ' ... ' Create two panels. Dim dp1 As DockPanel = DockManager1.AddPanel(DockingStyle.Left) dp1.Text = "Panel 1" Dim dp2 As DockPanel = DockManager1.AddPanel(DockingStyle.Float) dp2.Text = "Panel 2" ' Dock the dp2 panel to the dp1 panel. This will create a split container. dp2.DockTo(dp1) ' Create a floating panel. Dim dp3 As DockPanel = DockManager1.AddPanel(DockingStyle.Float) dp3.Text = "Panel 3" ' Dock this panel to the split container at the first position. dp3.DockTo(dp1.ParentPanel, 0) |