Assembly: System.Windows.Forms (in system.windows.forms.dll)
/** @property */ public DockStyle get_Dock () /** @property */ public void set_Dock (DockStyle value)
Property ValueOne of the DockStyle values. The default value is None.
You can dock a SplitContainer to any edge of its container, or you can dock a SplitContainer to all edges of the container so that the SplitContainer entirely fills the container. For example, set this property to DockStyle.Left to attach the left edge of the SplitContainer to the left edge of its container. Controls are docked in z-order.
The z-order corresponds to the depth dimension of the screen, and the x-order and y-order corresponds to the horizontal and vertical dimensions, respectively. Z-order defines which object appears in front of which, in cases where controls or windows can overlap or occupy the same space on the screen. A control or window at the top of the z-order appears on top of all other controls or windows and is referenced by an index of 0 in the Controls property. A control or window at the bottom of the z-order appears underneath all other controls or windows and is referenced by an index of (Controls.Count-1) in the Controls property.
For more information about anchoring and docking controls, see How to: Create a Multipane User Interface with Windows Forms.
The following code example shows a vertical splitter whose Dock property is set to Fill. Other basic properties of a vertical splitter are also shown. This example is part of a larger example provided for the SplitContainer class.
// Basic SplitContainer properties. // This is a vertical splitter that moves in 10-pixel increments. // This splitter needs no explicit Orientation property because Vertical is the default. splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill; splitContainer1.ForeColor = System.Drawing.SystemColors.Control; splitContainer1.Location = new System.Drawing.Point(0, 0); splitContainer1.Name = "splitContainer1"; // You can drag the splitter no nearer than 30 pixels from the left edge of the container. splitContainer1.Panel1MinSize = 30; // You can drag the splitter no nearer than 20 pixels from the right edge of the container. splitContainer1.Panel2MinSize = 20; splitContainer1.Size = new System.Drawing.Size(292, 273); splitContainer1.SplitterDistance = 79; // This splitter moves in 10-pixel increments. splitContainer1.SplitterIncrement = 10; splitContainer1.SplitterWidth = 6; // splitContainer1 is the first control in the tab order. splitContainer1.TabIndex = 0; splitContainer1.Text = "splitContainer1"; // When the splitter moves, the cursor changes shape. splitContainer1.SplitterMoved += new System.Windows.Forms.SplitterEventHandler(splitContainer1_SplitterMoved); splitContainer1.SplitterMoving += new System.Windows.Forms.SplitterCancelEventHandler(splitContainer1_SplitterMoving); // Add a TreeView control to the left panel. splitContainer1.Panel1.BackColor = System.Drawing.SystemColors.Control; // Add a TreeView control to Panel1. splitContainer1.Panel1.Controls.Add(treeView1); splitContainer1.Panel1.Name = "splitterPanel1"; // Controls placed on Panel1 support right-to-left fonts. splitContainer1.Panel1.RightToLeft = System.Windows.Forms.RightToLeft.Yes;
// Basic SplitContainer properties. // This is a vertical splitter that moves in 10-pixel increments. // This splitter needs no explicit Orientation property because // Vertical is the default. splitContainer1.set_Dock(System.Windows.Forms.DockStyle.Fill); splitContainer1.set_ForeColor(System.Drawing.SystemColors.get_Control()); splitContainer1.set_Location(new System.Drawing.Point(0, 0)); splitContainer1.set_Name("splitContainer1"); // You can drag the splitter no nearer than 30 pixels from the // left edge of the container. splitContainer1.set_Panel1MinSize(30); // You can drag the splitter no nearer than 20 pixels from the // right edge of the container. splitContainer1.set_Panel2MinSize(20); splitContainer1.set_Size(new System.Drawing.Size(292, 273)); splitContainer1.set_SplitterDistance(79); // This splitter moves in 10-pixel increments. splitContainer1.set_SplitterIncrement(10); splitContainer1.set_SplitterWidth(6); // splitContainer1 is the first control in the tab order. splitContainer1.set_TabIndex(0); splitContainer1.set_Text("splitContainer1"); // When the splitter moves, the cursor changes shape. splitContainer1.add_SplitterMoved(new System.Windows.Forms. SplitterEventHandler(splitContainer1_SplitterMoved)); splitContainer1.add_SplitterMoving(new System.Windows.Forms. SplitterCancelEventHandler(splitContainer1_SplitterMoving)); // Add a TreeView control to the left panel. splitContainer1.get_Panel1().set_BackColor(System.Drawing.SystemColors. get_Control()); // Add a TreeView control to Panel1. splitContainer1.get_Panel1().get_Controls().Add(treeView1); splitContainer1.get_Panel1().set_Name("splitterPanel1"); // Controls placed on Panel1 support right-to-left fonts. splitContainer1.get_Panel1().set_RightToLeft(System.Windows.Forms. RightToLeft.Yes);
Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter EditionThe Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.