ToolStrip Control Overview (Windows Forms)
The Windows Forms ToolStrip control and its associated classes provide a common framework for combining user interface elements into toolbars, status bars, and menus. ToolStrip controls offer a rich design-time experience that includes in-place activation and editing, custom layout, and rafting, which is the ability of toolbars to share horizontal or vertical space.
Although ToolStrip replaces and adds functionality to the control in previous versions, ToolBar is retained for both backward compatibility and future use if desired.
Features of the ToolStrip Controls
Use the ToolStrip control to:
Present a common user interface across containers.
Create easily customized, commonly employed toolbars that support advanced user interface and layout features, such as docking, rafting, buttons with text and images, drop-down buttons and controls, overflow buttons, and run-time reordering of ToolStrip items.
Support overflow and run-time item reordering. The overflow feature moves items to a drop-down menu when there is not enough room to display them in a ToolStrip.
Support the typical appearance and behavior of the operating system through a common rendering model.
Handle events consistently for all containers and contained items, in the same way you handle events for other controls.
Drag items from one ToolStrip to another or within a ToolStrip.
Create drop-down controls and user interface type editors with advanced layouts in a ToolStripDropDown.
Use the ToolStripControlHost class to use other controls on a ToolStrip and gain ToolStrip functionality for them.
You can extend the functionality and modify the appearance and behavior by using the ToolStripRenderer, ToolStripProfessionalRenderer, and ToolStripManager along with the ToolStripRenderMode and ToolStripManagerRenderMode enumerations.
The ToolStrip control is highly configurable and extensible, and it provides many properties, methods, and events to customize appearance and behavior. Below are some noteworthy members:
Important ToolStrip Members
Name |
Description |
---|---|
Gets or sets which edge of the parent container a ToolStrip is docked to. |
|
Gets or sets a value indicating whether drag-and-drop and item reordering are handled privately by the ToolStrip class. |
|
Gets or sets a value indicating how the ToolStrip lays out its items. |
|
Gets or sets whether a ToolStripItem is attached to the ToolStrip or ToolStripOverflowButton or can float between the two. |
|
Gets a value indicating whether a ToolStripItem displays other items in a drop-down list when the ToolStripItem is clicked. |
|
Gets the ToolStripItem that is the overflow button for a ToolStrip with overflow enabled. |
|
Gets or sets a ToolStripRenderer used to customize the appearance and behavior (look and feel) of a ToolStrip. |
|
Gets or sets the painting styles to be applied to the ToolStrip. |
|
Raised when the Renderer property changes. |
The ToolStrip control's flexibility is achieved through the use of a number of companion classes. Below are some of the most noteworthy:
Important ToolStrip Companion Classes
Name |
Description |
---|---|
Replaces and adds functionality to the MainMenu class. |
|
Replaces and adds functionality to the StatusBar class. |
|
Replaces and adds functionality to the ContextMenu class. |
|
Abstract base class that manages events and layout for all the elements that a ToolStrip, ToolStripControlHost, or ToolStripDropDown can contain. |
|
Provides a container with a panel on each side of the form in which controls can be arranged in various ways. |
|
Handles the painting functionality for ToolStrip objects. |
|
Provides Microsoft Office-style appearance. |
|
Controls ToolStrip rendering and rafting, and the merging of MenuStrip, ToolStripDropDownMenu, and ToolStripMenuItem objects. |
|
Specifies the painting style (custom, Windows XP, or Microsoft Office Professional) applied to multiple ToolStrip objects contained in a form. |
|
Specifies the painting style (custom, Windows XP, or Microsoft Office Professional) applied to one ToolStrip object contained in a form. |
|
Hosts other controls that are not specifically ToolStrip controls but for which you want ToolStrip functionality. |
|
Specifies whether a ToolStripItem is to be laid out on the main ToolStrip, on the overflow ToolStrip, or neither. |
For more information, see ToolStrip Technology Summary and ToolStrip Control Architecture.