ToolStripRenderer Class
Handles the painting functionality for ToolStrip objects.
System.Windows.Forms::ToolStripRenderer
System.Windows.Forms::ToolStripProfessionalRenderer
System.Windows.Forms::ToolStripSystemRenderer
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
The ToolStripRenderer type exposes the following members.
| Name | Description | |
|---|---|---|
![]() | RenderArrow | Occurs when an arrow on a ToolStripItem is rendered. |
![]() | RenderButtonBackground | Occurs when the background for a ToolStripButton is rendered |
![]() | RenderDropDownButtonBackground | Occurs when the background for a ToolStripDropDownButton is rendered. |
![]() | RenderGrip | Occurs when the move handle for a ToolStrip is rendered. |
![]() | RenderImageMargin | Draws the margin between an image and its container. |
![]() | RenderItemBackground | Occurs when the background for a ToolStripItem is rendered. |
![]() | RenderItemCheck | Occurs when the image for a selected ToolStripItem is rendered. |
![]() | RenderItemImage | Occurs when the image for a ToolStripItem is rendered. |
![]() | RenderItemText | Occurs when the text for a ToolStripItem is rendered. |
![]() | RenderLabelBackground | Occurs when the background for a ToolStripLabel is rendered. |
![]() | RenderMenuItemBackground | Occurs when the background for a ToolStripMenuItem is rendered. |
![]() | RenderOverflowButtonBackground | Occurs when the background for an overflow button is rendered. |
![]() | RenderSeparator | Occurs when a ToolStripSeparator is rendered. |
![]() | RenderSplitButtonBackground | Occurs when the background for a ToolStripSplitButton is rendered. |
![]() | RenderStatusStripSizingGrip | Occurs when the display style changes. |
![]() | RenderToolStripBackground | Occurs when the background for a ToolStrip is rendered. |
![]() | RenderToolStripBorder | Occurs when the border for a ToolStrip is rendered. |
![]() | RenderToolStripContentPanelBackground | Draws the background of a ToolStripContentPanel. |
![]() | RenderToolStripPanelBackground | Draws the background of a ToolStripPanel. |
![]() | RenderToolStripStatusLabelBackground | Draws the background of a ToolStripStatusLabel. |
Use the ToolStripRenderer class to apply a particular style or theme to a ToolStrip. Rather than custom painting a ToolStrip and the ToolStripItem objects it contains, you set the ToolStrip::Renderer property to an object that inherits from ToolStripRenderer. The painting specified by the ToolStripRenderer is applied to the ToolStrip, as well as the items it contains.
You can do custom painting in ToolStrip controls in several ways. As with other Windows Forms controls, the ToolStrip and ToolStripItem both have overridable OnPaint methods and Paint events. As with regular painting, the coordinate system is relative to the client area of the control; that is, the upper left-hand corner of the control is 0, 0. The Paint event and OnPaint method for a ToolStripItem behave like other control paint events.
The ToolStripRenderer class has overridable methods for painting the background, item background, item image, item arrow, item text, and border of the ToolStrip. The event arguments for these methods expose several properties such as rectangles, colors, and text formats that you can adjust as desired.
To adjust just a few aspects of how an item is painted, you typically override the ToolStripRenderer.
If you are writing a new item and want to control all aspects of the painting, override the OnPaint method. From within OnPaint, you can use methods from the ToolStripRenderer.
By default, the ToolStrip is double buffered, taking advantage of the OptimizedDoubleBuffer setting.
The following code example demonstrates how to implement a custom ToolStripRenderer class. The GridStripRenderer class customizes three aspects of the GridStrip control's appearance: GridStrip border, ToolStripButton border, and ToolStripButton image. For a full code listing, see How to: Implement a Custom ToolStripRenderer.
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
