System.Windows.Forms.ToolStripRenderer Class

Handles the painting functionality for System.Windows.Forms.ToolStrip objects.

See Also: ToolStripRenderer Members

Syntax

public abstract class ToolStripRenderer

Remarks

Use the System.Windows.Forms.ToolStripRenderer class to apply a particular style or theme to a System.Windows.Forms.ToolStrip. Rather than custom painting a System.Windows.Forms.ToolStrip and the System.Windows.Forms.ToolStripItem objects it contains, you set the ToolStrip.Renderer property to an object that inherits from System.Windows.Forms.ToolStripRenderer. The painting specified by the System.Windows.Forms.ToolStripRenderer is applied to the System.Windows.Forms.ToolStrip, as well as the items it contains.

You can do custom painting in System.Windows.Forms.ToolStrip controls in several ways. As with other Windows Forms controls, the System.Windows.Forms.ToolStrip and System.Windows.Forms.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 System.Windows.Forms.ToolStripItem behave like other control paint events.

The System.Windows.Forms.ToolStripRenderer class has overridable methods for painting the background, item background, item image, item arrow, item text, and border of the System.Windows.Forms.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 System.Windows.Forms.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 System.Windows.Forms.ToolStripRenderer.

By default, the System.Windows.Forms.ToolStrip is double buffered, taking advantage of the ControlStyles.OptimizedDoubleBuffer setting.

Requirements

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
Assembly Versions: 2.0.0.0
Since: .NET 2.0