Udostępnij za pośrednictwem


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 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

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 defaultis AsNeeded.

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

See Also

Concepts

ToolStrip Control Architecture

ToolStrip Technology Summary

Reference

ToolStrip Control Overview (Windows Forms)

ToolStrip

ToolStripOverflowButton

Overflow

CanOverflow