ToolStripRenderer Class
Handles the painting functionality for ToolStrip objects.
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
System.Windows.Forms::ToolStripRenderer
System.Windows.Forms::ToolStripProfessionalRenderer
System.Windows.Forms::ToolStripSystemRenderer
| Name | Description | |
|---|---|---|
![]() | ToolStripRenderer() | Initializes a new instance of the ToolStripRenderer class. |
| Name | Description | |
|---|---|---|
![]() ![]() | Offset2X | This API supports the product infrastructure and is not intended to be used directly from your code. Gets or sets the offset multiplier for twice the offset along the x-axis. |
![]() ![]() | Offset2Y | This API supports the product infrastructure and is not intended to be used directly from your code. Gets or sets the offset multiplier for twice the offset along the y axis. |
| 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.
Available since 2.0
Any public static ( Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.




