ToolStrip Control Overview (Windows forms)
Using ToolStrip and its associated classes, you can create toolbars and other user interface elements that have Microsoft Windows XP, Microsoft Office, Microsoft Internet Explorer, or custom appearance and behavior. These elements support overflow and Run-time item reordering. The ToolStrip control provides a rich design-time experience, including in-place activation and editing, custom layout, floating (that is, the ability of toolbars to share horizontal or vertical space).
Although ToolStrip replaces earlier versions of the controls and adds functionality, you can still choose to reserve ToolBar for backward compatibility and future use when needed.
Functions of the ToolStrip control
You can use the ToolStrip control to:
Create easy to customize common toolbars that support advanced user interface and layout features such as docked, floating, text and image buttons, Drop-down buttons and controls, overflow buttons, and run-time reordering of ToolStrip items.
Supports the typical appearance and behavior of the operating system.
Event consistency is handled for all containers and included items in the same way as events for other controls.
Drag items from one ToolStrip to another ToolStrip.
Use the advanced layout in ToolStripDropDown to create a Drop-down control and a user interface type editor.
Use the ToolStripControlHost class to work with other controls in ToolStrip and get ToolStrip functionality for them.
By using the ToolStripRenderer, Toolstripprofessionalrenderer, and Toolstripmanager and Toolstriprendermode enumerations and Toolstripmanagerrendermode enumeration, you can extend this functionality and modify the appearance and behavior.
The ToolStrip control is a highly configurable, extensible control that provides a number of properties, methods, and events that you can use to customize appearance and behavior. The following are some notable members:
Important members of the ToolStrip
name |
Description |
Dock |
Gets or sets which edge of the parent container the ToolStrip is docked to. |
Allowitemreorder |
Gets or sets a value that indicates whether drag-and-drop and item reordering are handled specifically by the ToolStrip class. |
Layoutstyle |
Gets or sets a value that indicates how ToolStrip will lay out its items. |
Overflow |
Gets or sets whether the ToolStripItem is attached to the ToolStrip, attached to the Toolstripoverflowbutton, or let it float between the two. |
Isdropdown |
Gets a value that indicates whether ToolStripItem displays other items in the Drop-down list when the ToolStripItem is clicked. |
Overflowbutton |
Gets the ToolStripItem, which is an overflow button with overflow ToolStrip enabled. |
Renderer |
Gets or sets a toolstriprenderer that is used to customize the appearance and behavior (appearance) of ToolStrip. |
Rendermode |
Gets or sets the drawing style to apply to the ToolStrip. |
Rendererchanged |
Raised when the Renderer property is changed. |
The flexibility of ToolStrip controls can be achieved by using multiple accompanying classes. Here are some of the most notable accompanying classes:
The important ToolStrip accompanying class
name |
Description |
MenuStrip |
Replace the MainMenu class and add functionality. |
StatusStrip |
Replace the StatusBar class and add functionality. |
ContextMenuStrip |
Replace the ContextMenu class and add functionality. |
ToolStripItem |
Abstract base class that manages events and layouts for all elements that ToolStrip, toolstripcontrolhost, or ToolStripDropDown can contain. |
ToolStripContainer |
Provides a container in which each side of the form is provided with a panel, and the controls in the panel can be arranged in a variety of ways. |
ToolStripRenderer |
Handles the drawing function of the ToolStrip object. |
Toolstripprofessionalrenderer |
Provides the appearance of the Microsoft Office style. |
Toolstripmanager |
Controls ToolStrip rendering and floating, and controls the merging of MenuStrip objects, Toolstripdropdownmenu objects, and ToolStripMenuItem objects. |
Toolstripmanagerrendermode |
Specifies the drawing style (custom, Windows XP, or Microsoft Office Professional) that applies to multiple ToolStrip objects in a form. |
Toolstriprendermode |
Specifies the drawing style (custom, Windows XP, or Microsoft Office Professional) that applies to a ToolStrip object in a form. |
ToolStripControlHost |
Hosts other controls that are not explicit ToolStrip controls, but that you need to provide TOOLSTRIP functionality for. |
Toolstripitemplacement |
Specifies whether the ToolStripItem is laid out in the main ToolStrip, whether it is laid out in an overflow ToolStrip, or none is laid out. |
For more information, see ToolStrip Technical Summary and TOOLSTRIP control structure.
Original address: Msdn2.microsoft.com/zh-cn/library/e58c44b8 (vs.80). aspx