This documentation is archived and is not being maintained.

ToolStripProfessionalRenderer Class

Handles the painting functionality for ToolStrip objects, applying a custom palette and a streamlined style.


Namespace:  System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

public class ToolStripProfessionalRenderer : ToolStripRenderer

The ToolStripProfessionalRenderer type exposes the following members.

Public methodToolStripProfessionalRenderer()Initializes a new instance of the ToolStripProfessionalRenderer class.
Public methodToolStripProfessionalRenderer(ProfessionalColorTable)Initializes a new instance of the ToolStripProfessionalRenderer class.

Public propertyColorTableGets the color palette used for painting.
Public propertyRoundedEdgesGets or sets a value indicating whether edges of controls have a rounded rather than a square or sharp appearance.

Public methodDrawArrowDraws an arrow on a ToolStripItem. (Inherited from ToolStripRenderer.)
Public methodDrawButtonBackgroundDraws the background for a ToolStripButton. (Inherited from ToolStripRenderer.)
Public methodDrawDropDownButtonBackgroundDraws the background for a ToolStripDropDownButton. (Inherited from ToolStripRenderer.)
Public methodDrawGripDraws a move handle on a ToolStrip. (Inherited from ToolStripRenderer.)
Public methodDrawImageMarginDraws the space around an image on a ToolStrip. (Inherited from ToolStripRenderer.)
Public methodDrawItemBackgroundDraws the background for a ToolStripItem. (Inherited from ToolStripRenderer.)
Public methodDrawItemCheckDraws an image on a ToolStripItem that indicates the item is in a selected state. (Inherited from ToolStripRenderer.)
Public methodDrawItemImageDraws an image on a ToolStripItem. (Inherited from ToolStripRenderer.)
Public methodDrawItemTextDraws text on a ToolStripItem. (Inherited from ToolStripRenderer.)
Public methodDrawLabelBackgroundDraws the background for a ToolStripLabel. (Inherited from ToolStripRenderer.)
Public methodDrawMenuItemBackgroundDraws the background for a ToolStripMenuItem. (Inherited from ToolStripRenderer.)
Public methodDrawOverflowButtonBackgroundDraws the background for an overflow button. (Inherited from ToolStripRenderer.)
Public methodDrawSeparatorDraws a ToolStripSeparator. (Inherited from ToolStripRenderer.)
Public methodDrawSplitButtonDraws a ToolStripSplitButton. (Inherited from ToolStripRenderer.)
Public methodDrawStatusStripSizingGripDraws a sizing grip. (Inherited from ToolStripRenderer.)
Public methodDrawToolStripBackgroundDraws the background for a ToolStrip. (Inherited from ToolStripRenderer.)
Public methodDrawToolStripBorderDraws the border for a ToolStrip. (Inherited from ToolStripRenderer.)
Public methodDrawToolStripContentPanelBackgroundDraws the background of the ToolStripContentPanel. (Inherited from ToolStripRenderer.)
Public methodDrawToolStripPanelBackgroundDraws the background of the ToolStripPanel. (Inherited from ToolStripRenderer.)
Public methodDrawToolStripStatusLabelBackgroundDraws the background of the ToolStripStatusLabel. (Inherited from ToolStripRenderer.)
Public methodEquals(Object)Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodGetHashCodeServes as a hash function for a particular type. (Inherited from Object.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Protected methodInitializeWhen overridden in a derived class, provides for custom initialization of the given ToolStrip. (Inherited from ToolStripRenderer.)
Protected methodInitializeContentPanelInitializes the specified ToolStripContentPanel. (Inherited from ToolStripRenderer.)
Protected methodInitializeItemWhen overridden in a derived class, provides for custom initialization of the given ToolStripItem. (Inherited from ToolStripRenderer.)
Protected methodInitializePanelInitializes the specified ToolStripPanel. (Inherited from ToolStripRenderer.)
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Protected methodOnRenderArrowRaises the RenderArrow event. (Overrides ToolStripRenderer.OnRenderArrow(ToolStripArrowRenderEventArgs).)
Protected methodOnRenderButtonBackgroundRaises the RenderButtonBackground event. (Overrides ToolStripRenderer.OnRenderButtonBackground(ToolStripItemRenderEventArgs).)
Protected methodOnRenderDropDownButtonBackgroundRaises the RenderDropDownButtonBackground event. (Overrides ToolStripRenderer.OnRenderDropDownButtonBackground(ToolStripItemRenderEventArgs).)
Protected methodOnRenderGripRaises the RenderGrip event. (Overrides ToolStripRenderer.OnRenderGrip(ToolStripGripRenderEventArgs).)
Protected methodOnRenderImageMarginDraws the item background. (Overrides ToolStripRenderer.OnRenderImageMargin(ToolStripRenderEventArgs).)
Protected methodOnRenderItemBackgroundRaises the OnRenderItemBackground event. (Inherited from ToolStripRenderer.)
Protected methodOnRenderItemCheckRaises the RenderItemCheck event. (Overrides ToolStripRenderer.OnRenderItemCheck(ToolStripItemImageRenderEventArgs).)
Protected methodOnRenderItemImageRaises the RenderItemImage event. (Overrides ToolStripRenderer.OnRenderItemImage(ToolStripItemImageRenderEventArgs).)
Protected methodOnRenderItemTextRaises the RenderItemText event. (Overrides ToolStripRenderer.OnRenderItemText(ToolStripItemTextRenderEventArgs).)
Protected methodOnRenderLabelBackgroundRaises the RenderLabelBackground event. (Overrides ToolStripRenderer.OnRenderLabelBackground(ToolStripItemRenderEventArgs).)
Protected methodOnRenderMenuItemBackgroundRaises the RenderMenuItemBackground event. (Overrides ToolStripRenderer.OnRenderMenuItemBackground(ToolStripItemRenderEventArgs).)
Protected methodOnRenderOverflowButtonBackgroundRaises the RenderOverflowButtonBackground event. (Overrides ToolStripRenderer.OnRenderOverflowButtonBackground(ToolStripItemRenderEventArgs).)
Protected methodOnRenderSeparatorRaises the RenderSeparator event. (Overrides ToolStripRenderer.OnRenderSeparator(ToolStripSeparatorRenderEventArgs).)
Protected methodOnRenderSplitButtonBackgroundRaises the OnRenderSplitButtonBackground event. (Overrides ToolStripRenderer.OnRenderSplitButtonBackground(ToolStripItemRenderEventArgs).)
Protected methodOnRenderStatusStripSizingGripRaises the RenderStatusStripSizingGrip event. (Inherited from ToolStripRenderer.)
Protected methodOnRenderToolStripBackgroundRaises the RenderToolStripBackground event. (Overrides ToolStripRenderer.OnRenderToolStripBackground(ToolStripRenderEventArgs).)
Protected methodOnRenderToolStripBorderRaises the RenderToolStripBorder event. (Overrides ToolStripRenderer.OnRenderToolStripBorder(ToolStripRenderEventArgs).)
Protected methodOnRenderToolStripContentPanelBackgroundRaises the RenderToolStripContentPanelBackground event. (Overrides ToolStripRenderer.OnRenderToolStripContentPanelBackground(ToolStripContentPanelRenderEventArgs).)
Protected methodOnRenderToolStripPanelBackgroundRaises the RenderToolStripPanelBackground event. (Overrides ToolStripRenderer.OnRenderToolStripPanelBackground(ToolStripPanelRenderEventArgs).)
Protected methodOnRenderToolStripStatusLabelBackgroundRaises the RenderToolStripStatusLabelBackground event. (Overrides ToolStripRenderer.OnRenderToolStripStatusLabelBackground(ToolStripItemRenderEventArgs).)
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)

Public eventRenderArrowOccurs when an arrow on a ToolStripItem is rendered. (Inherited from ToolStripRenderer.)
Public eventRenderButtonBackgroundOccurs when the background for a ToolStripButton is rendered (Inherited from ToolStripRenderer.)
Public eventRenderDropDownButtonBackgroundOccurs when the background for a ToolStripDropDownButton is rendered. (Inherited from ToolStripRenderer.)
Public eventRenderGripOccurs when the move handle for a ToolStrip is rendered. (Inherited from ToolStripRenderer.)
Public eventRenderImageMarginDraws the margin between an image and its container. (Inherited from ToolStripRenderer.)
Public eventRenderItemBackgroundOccurs when the background for a ToolStripItem is rendered. (Inherited from ToolStripRenderer.)
Public eventRenderItemCheckOccurs when the image for a selected ToolStripItem is rendered. (Inherited from ToolStripRenderer.)
Public eventRenderItemImageOccurs when the image for a ToolStripItem is rendered. (Inherited from ToolStripRenderer.)
Public eventRenderItemTextOccurs when the text for a ToolStripItem is rendered. (Inherited from ToolStripRenderer.)
Public eventRenderLabelBackgroundOccurs when the background for a ToolStripLabel is rendered. (Inherited from ToolStripRenderer.)
Public eventRenderMenuItemBackgroundOccurs when the background for a ToolStripMenuItem is rendered. (Inherited from ToolStripRenderer.)
Public eventRenderOverflowButtonBackgroundOccurs when the background for an overflow button is rendered. (Inherited from ToolStripRenderer.)
Public eventRenderSeparatorOccurs when a ToolStripSeparator is rendered. (Inherited from ToolStripRenderer.)
Public eventRenderSplitButtonBackgroundOccurs when the background for a ToolStripSplitButton is rendered. (Inherited from ToolStripRenderer.)
Public eventRenderStatusStripSizingGripOccurs when the display style changes. (Inherited from ToolStripRenderer.)
Public eventRenderToolStripBackgroundOccurs when the background for a ToolStrip is rendered. (Inherited from ToolStripRenderer.)
Public eventRenderToolStripBorderOccurs when the border for a ToolStrip is rendered. (Inherited from ToolStripRenderer.)
Public eventRenderToolStripContentPanelBackgroundDraws the background of a ToolStripContentPanel. (Inherited from ToolStripRenderer.)
Public eventRenderToolStripPanelBackgroundDraws the background of a ToolStripPanel. (Inherited from ToolStripRenderer.)
Public eventRenderToolStripStatusLabelBackgroundDraws the background of a ToolStripStatusLabel. (Inherited from ToolStripRenderer.)

ToolStripProfessionalRenderer creates pens and brushes based on a replaceable color table called ProfessionalColorTable.

The following code example demonstrates how to create a composite control that mimics the Navigation Pane provided by Microsoft® Outlook®. For a full code listing, see How to: Create a Professionally Styled ToolStrip Control.

internal class StackRenderer : ToolStripProfessionalRenderer
    private static Bitmap titleBarGripBmp;
    private static string titleBarGripEnc = @"Qk16AQAAAAAAADYAAAAoAAAAIwAAAAMAAAABABgAAAAAAAAAAADEDgAAxA4AAAAAAAAAAAAAuGMy+/n5+/n5uGMyuGMy+/n5+/n5uGMyuGMy+/n5+/n5uGMyuGMy+/n5+/n5uGMyuGMy+/n5+/n5uGMyuGMy+/n5+/n5uGMyuGMy+/n5+/n5uGMyuGMy+/n5+/n5uGMyuGMy+/n5+/n5ANj+RzIomHRh+/n5wm8/RzIomHRh+/n5wm8/RzIomHRh+/n5wm8/RzIomHRh+/n5wm8/RzIomHRh+/n5wm8/RzIomHRh+/n5wm8/RzIomHRh+/n5wm8/RzIomHRh+/n5wm8/RzIomHRh+/n5ANj+RzIoRzIozHtMzHtMRzIoRzIozHtMzHtMRzIoRzIozHtMzHtMRzIoRzIozHtMzHtMRzIoRzIozHtMzHtMRzIoRzIozHtMzHtMRzIoRzIozHtMzHtMRzIoRzIozHtMzHtMRzIoRzIozHtMANj+";

    // Define titlebar colors.
    private static Color titlebarColor1 = Color.FromArgb(89, 135, 214);
    private static Color titlebarColor2 = Color.FromArgb(76, 123, 204);
    private static Color titlebarColor3 = Color.FromArgb(63, 111, 194);
    private static Color titlebarColor4 = Color.FromArgb(50, 99, 184);
    private static Color titlebarColor5 = Color.FromArgb(38, 88, 174);
    private static Color titlebarColor6 = Color.FromArgb(25, 76, 164);
    private static Color titlebarColor7 = Color.FromArgb(12, 64, 154);
    private static Color borderColor = Color.FromArgb(0, 0, 128);

    static StackRenderer()
        titleBarGripBmp = StackView.DeserializeFromBase64(titleBarGripEnc);

    public StackRenderer()

    private void DrawTitleBar(Graphics g, Rectangle rect)
        // Assign the image for the grip.
        Image titlebarGrip = titleBarGripBmp;

        // Fill the titlebar. 
        // This produces the gradient and the rounded-corner effect.
        g.DrawLine(new Pen(titlebarColor1), rect.X, rect.Y, rect.X + rect.Width, rect.Y);
        g.DrawLine(new Pen(titlebarColor2), rect.X, rect.Y + 1, rect.X + rect.Width, rect.Y + 1);
        g.DrawLine(new Pen(titlebarColor3), rect.X, rect.Y + 2, rect.X + rect.Width, rect.Y + 2);
        g.DrawLine(new Pen(titlebarColor4), rect.X, rect.Y + 3, rect.X + rect.Width, rect.Y + 3);
        g.DrawLine(new Pen(titlebarColor5), rect.X, rect.Y + 4, rect.X + rect.Width, rect.Y + 4);
        g.DrawLine(new Pen(titlebarColor6), rect.X, rect.Y + 5, rect.X + rect.Width, rect.Y + 5);
        g.DrawLine(new Pen(titlebarColor7), rect.X, rect.Y + 6, rect.X + rect.Width, rect.Y + 6);

        // Center the titlebar grip.
            new Point(rect.X + ((rect.Width / 2) - (titlebarGrip.Width / 2)),
            rect.Y + 1));

    // This method handles the RenderGrip event.
    protected override void OnRenderGrip(ToolStripGripRenderEventArgs e)
            new Rectangle(0, 0, e.ToolStrip.Width, 7));

    // This method handles the RenderToolStripBorder event.
    protected override void OnRenderToolStripBorder(ToolStripRenderEventArgs e)
            new Rectangle(0, 0, e.ToolStrip.Width, 7));

    // This method handles the RenderButtonBackground event.
    protected override void OnRenderButtonBackground(ToolStripItemRenderEventArgs e)
        Graphics g = e.Graphics;
        Rectangle bounds = new Rectangle(Point.Empty, e.Item.Size);

        Color gradientBegin = Color.FromArgb(203, 225, 252);
        Color gradientEnd = Color.FromArgb(125, 165, 224);

        ToolStripButton button = e.Item as ToolStripButton;
        if (button.Pressed || button.Checked)
            gradientBegin = Color.FromArgb(254, 128, 62);
            gradientEnd = Color.FromArgb(255, 223, 154);
        else if (button.Selected)
            gradientBegin = Color.FromArgb(255, 255, 222);
            gradientEnd = Color.FromArgb(255, 203, 136);

        using (Brush b = new LinearGradientBrush(
            g.FillRectangle(b, bounds);


            bounds.Width - 1,

            bounds.Height - 1);

        ToolStrip toolStrip = button.Owner;
        ToolStripButton nextItem = button.Owner.GetItemAt(
            button.Bounds.Bottom + 1) as ToolStripButton;

        if (nextItem == null)
                bounds.Height - 1,
                bounds.X + bounds.Width - 1,
                bounds.Height - 1);

.NET Framework

Supported in: 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

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.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.