示例 1
在下列代码中,创建了两个浮动面板,然后把它们停靠到由停靠管理器的 DockManager.Form 属性引用的窗体中。 为了把面板停靠到窗体中,使用了 DockPanel.DockTo 方法。
面板被停靠的顺序确定了停靠面板在窗体内的布局。 第一个面板将会完全占用窗体的左边缘,而第二个面板将仅被停靠在未被第一个面板占用的区域中。
结果显示如下:
C# | 复制代码 |
---|---|
using DevExpress.XtraBars.Docking; // Create two floating panels. DockPanel dp1 = DockManager1.AddPanel(DockingStyle.Float); dp1.Text = "Panel 1"; DockPanel dp2 = DockManager1.AddPanel(DockingStyle.Float); dp2.Text = "Panel 2"; // Dock the first panel to left. dp1.DockTo(DockingStyle.Left); // Dock the second panel to bottom. // This panel will be docked within the form's area that isn't occupied by the first panel. dp2.DockTo(DockingStyle.Bottom); |
Visual Basic | 复制代码 |
---|---|
Imports DevExpress.XtraBars.Docking ' ... ' Create two floating panels. Dim dp1 As DockPanel = DockManager1.AddPanel(DockingStyle.Float) dp1.Text = "Panel 1" Dim dp2 As DockPanel = DockManager1.AddPanel(DockingStyle.Float) dp2.Text = "Panel 2" ' Dock the first panel to left. dp1.DockTo(DockingStyle.Left) ' Dock the second panel to bottom. ' This panel will be docked within the form's area that isn't occupied by the first panel. dp2.DockTo(DockingStyle.Bottom) |
示例 2
在下列代码中创建了两个面板,并分别把它们停靠到窗体的左边缘和下边缘。 然后新建一个浮动面板,把它停靠到窗体的下边缘来让它完全占用下边缘。 通过 DockPanel.DockTo 方法来停靠面板。
要把某个面板停靠到已有面板之间的特定位置,则需要使用 DockPanel.DockTo 的有 index 参数的重载。 如果把 index 设置为 0,则该面板将完全占用相应的窗体边缘。
结果显示如下:
C# | 复制代码 |
---|---|
using DevExpress.XtraBars.Docking; // Create two floating panels. DockPanel dp1 = dockManager1.AddPanel(DockingStyle.Float); dp1.Text = "Panel 1"; DockPanel dp2 = dockManager1.AddPanel(DockingStyle.Float); dp2.Text = "Panel 2"; // Dock the first panel on the left dp1.DockTo(DockingStyle.Left); // Dock the second panel to the bottom. // This panel will be docked within the form's area that isn't occupied by the first panel. dp2.DockTo(DockingStyle.Bottom); // Create a floating panel. DockPanel dp3 = dockManager1.AddPanel(DockingStyle.Float); dp3.Text = "Panel 3"; // Dock this panel so that it occupies the form's bottom edge entirely. dp3.DockTo(DockingStyle.Bottom, 0); |
Visual Basic | 复制代码 |
---|---|
Imports DevExpress.XtraBars.Docking ' Create two floating panels. Dim dp1 As DockPanel = DockManager1.AddPanel(DockingStyle.Float) dp1.Text = "Panel 1" Dim dp2 As DockPanel = DockManager1.AddPanel(DockingStyle.Float) dp2.Text = "Panel 2" ' Dock the first panel on the left dp1.DockTo(DockingStyle.Left) ' Dock the second panel to the bottom. ' This panel will be docked within the form's are that is not occupied by the first panel. dp2.DockTo(DockingStyle.Bottom) ' Create a floating panel. Dim dp3 As DockPanel = DockManager1.AddPanel(DockingStyle.Float) dp3.Text = "Panel 3" ' Dock this panel so that it occupies the form's bottom edge entirely. dp3.DockTo(DockingStyle.Bottom, 0) |