How to: Manage ToolStrip Overflow

How to: Manage ToolStrip Overflow in Windows Forms

When all the items on a ToolStrip control do not fit in the allotted space, you can enable overflow functionality on the ToolStrip and determine the overflow behavior of specific ToolStripItems.

When you add ToolStripItems that require more space than is allotted to the ToolStrip given the form's current size, a ToolStripOverflowButton automatically appears on the ToolStrip. The ToolStripOverflowButton appears, and overflow-enabled items are moved into the drop-down overflow menu. This allows you to customize and prioritize how your ToolStrip items properly adjust to different form sizes. You can also change the appearance of your items when they fall into the overflow by using the Placement and System.Windows.Forms.ToolStripOverflow.DisplayedItems properties and the LayoutCompleted event. If you enlarge the form at either design time or run time, more ToolStripItems can be displayed on the main ToolStrip and the ToolStripOverflowButton might even disappear until you decrease the size of the form.

To enable overflow on a ToolStrip control

  • Ensure that the CanOverflow property is not set to false for the ToolStrip. The default is True.

    When CanOverflow is True (the default), a ToolStripItem is sent to the drop-down overflow menu when the content of the ToolStripItem exceeds the width of a horizontal ToolStrip or the height of a vertical ToolStrip.

To specify overflow behavior of a specific ToolStripItem

  • Set the Overflow property of the ToolStripItem to the desired value. The possibilities are Always, Never, and AsNeeded. The default is AsNeeded.

    toolStripTextBox1.Overflow = _
    System.Windows.Forms.ToolStripItemOverflow.Never
    
    

    toolStripTextBox1.Overflow = _
    System.Windows.Forms.ToolStripItemOverflow.Never;
    
    

See Also

Community Additions

ADD
Show:
© 2016 Microsoft