ToolStripLayoutStyle Enum
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Specifies the possible alignments with which the items of a ToolStrip can be displayed.
public enum class ToolStripLayoutStyle
public enum ToolStripLayoutStyle
type ToolStripLayoutStyle =
Public Enum ToolStripLayoutStyle
- Inheritance
Fields
Name | Value | Description |
---|---|---|
StackWithOverflow | 0 | Specifies that items are laid out automatically. |
HorizontalStackWithOverflow | 1 | Specifies that items are laid out horizontally and overflow as necessary. |
VerticalStackWithOverflow | 2 | Specifies that items are laid out vertically, are centered within the control, and overflow as necessary. |
Flow | 3 | Specifies that items flow horizontally or vertically as necessary. |
Table | 4 | Specifies that items are laid out flush left. |
Remarks
You control the layout of the ToolStrip class and its derived classes by assigning a member of the ToolStripLayoutStyle enumeration to the control's LayoutStyle
property, such as the ToolStrip.LayoutStyle or StatusStrip.LayoutStyle property.
Stack Layouts
Stacking arranges items beside each other at both ends of the tool strip. The following list describes the stack layouts.
StackWithOverflow causes the tool strip to alter its layout automatically in accordance with the control's
Orientation
property to handle dragging and docking scenarios.VerticalStackWithOverflow renders the
Orientation
items beside each other vertically.HorizontalStackWithOverflow renders the
Orientation
items beside each other horizontally.
Other Features of Stack Layouts
Alignment determines the end of the HorizontalStackWithOverflow to which the item is aligned.
When items do not fit within the ToolStrip, an overflow button automatically appears. The Overflow property setting determines whether an item appears in the overflow area always, as needed, or never.
In the LayoutCompleted event, you can inspect the Placement property to determine whether an item was placed on the main Overflow, the overflow LayoutCompleted, or if it is not currently showing at all. The typical reasons why an item is not displayed are that the item did not fit on the main Placement and its Overflow property was set to ToolStripItemOverflow.
Make a ToolStrip movable by putting it in a ToolStripPanel and setting its GripStyle to ToolStripGripStyle.
Other Layout Options
The other layout options are Flow and Table.
Flow Layout
Flow layout is the default for ContextMenuStrip, ToolStripDropDownMenu, and ToolStripOverflow. It is similar to the FlowLayoutPanel. The features of Flow layout are as follows:
All of the features of FlowLayoutPanel are exposed by the LayoutSettings property. You must cast the LayoutSettings class to a FlowLayoutSettings class.
You can use the Dock and Anchor properties in code to align the items within the row.
The Alignment property is ignored.
In the LayoutCompleted event, you can inspect the Placement property to determine whether an item was placed on the main ToolStrip or did not fit.
The grip is not rendered, and therefore a ToolStrip in Flow layout style in a ToolStripPanel cannot be moved.
The Anchor overflow button is not rendered, and Overflow is ignored.
Table Layout
Table layout is the default for StatusStrip. It is similar to TableLayoutPanel. The features of Table layout are as follows:
All of the features of TableLayoutPanel are exposed by the LayoutSettings property. You must cast the LayoutSettings class to a TableLayoutSettings class.
You can use the Dock and Anchor properties in code to align the items within the table cell.
The Alignment property is ignored.
In the LayoutCompleted event, you can inspect the Placement property to determine whether an item was placed on the main Table or did not fit.
The grip is not rendered, and therefore a ToolStrip in Table layout style in a ToolStripPanel cannot be moved.
The ToolStrip overflow button is not rendered, and Overflow is ignored.