ToolStripItem.Dock 屬性


取得或設定停駐在其父控制項的 ToolStripItem 框線,並決定 ToolStripItem 隨其父代重新調整大小的方式。Gets or sets which ToolStripItem borders are docked to its parent control and determines how a ToolStripItem is resized with its parent.

 property System::Windows::Forms::DockStyle Dock { System::Windows::Forms::DockStyle get(); void set(System::Windows::Forms::DockStyle value); };
public System.Windows.Forms.DockStyle Dock { get; set; }
member this.Dock : System.Windows.Forms.DockStyle with get, set
Public Property Dock As DockStyle


其中一個 DockStyle 值。One of the DockStyle values. 預設值為 NoneThe default is None.



所指派的值不是其中一個 DockStyle 值。The value assigned is not one of the DockStyle values.


此屬性只適用于流程版面配置。This property applies only to flow layouts.

使用 [Dock] 屬性,即可定義如何在調整 ToolStripItem 的父控制項大小時自動調整其大小。Use the Dock property to define how a ToolStripItem is automatically resized as its parent control is resized. 例如,將 Dock 設定為 Left 會使 ToolStripItem 與父控制項的左邊緣對齊,並在調整父控制項的大小時調整大小。For example, setting Dock to Left causes the ToolStripItem to align itself with the left edges of its parent control and to resize as the parent control is resized. 控制項停駐在其迭置順序中,也就是表單上控制項的視覺分層,沿著表單的 Z 軸(深度)。Controls are docked in their Z-order, which is the visual layering of controls on a form along the form's Z-axis (depth).

控制項可以停駐在其父容器的一個邊緣,也可以停駐在所有邊緣,並填滿父容器。A control can be docked to one edge of its parent container or can be docked to all edges and fill the parent container.


AnchorDock 屬性互斥。The Anchor and Dock properties are mutually exclusive. 一次只能設定一個,而最後一個設定則優先。Only one can be set at a time, and the last one set takes precedence.