--- title: "How to: Custom Draw a ToolStrip Control" ms.date: "03/30/2017" dev_langs: - "csharp" - "vb" helpviewer_keywords: - "toolbars [Windows Forms], custom drawing" - "drawing [Windows Forms], owner" - "ProfessionalColorTable class [Windows Forms], overriding" - "examples [Windows Forms], toolbars" - "drawing [Windows Forms], custom" - "toolbars [Windows Forms], changing colors" - "ToolStrip control [Windows Forms], drawing" - "ToolStrip control [Windows Forms], changing colors" - "custom drawing" - "owner drawing" ms.assetid: 94e7d7bd-a752-441c-b5b3-7acf98881163 --- # How to: Custom Draw a ToolStrip Control The controls have the following associated rendering (painting) classes: - provides the appearance and style of your operating system. - provides the appearance and style of Microsoft Office. - is the abstract base class for the other two rendering classes. To custom draw (also known as owner draw) a , you can override one of the renderer classes and change an aspect of the rendering logic. The following procedures describe various aspects of custom drawing. ### To switch between the provided renderers - Set the property to the value you want. With , the static determines the renderer for your application. The other values of are , , and . ### To change the Microsoft Office–style borders to straight - Override , but do not call the base class. > [!NOTE] > There is a version of this method for , , and . ### To change the ProfessionalColorTable - Override and change the colors you want. ```vb Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As _ System.EventArgs) Handles Me.Load Dim t As MyColorTable = New MyColorTable ToolStrip1.Renderer = New ToolStripProfessionalRenderer(t) End Sub Class MyColorTable Inherits ProfessionalColorTable Public Overrides ReadOnly Property ButtonPressedGradientBegin() As Color Get Return Color.Red End Get End Property Public Overrides ReadOnly Property ButtonPressedGradientMiddle() _ As System.Drawing.Color Get Return Color.Blue End Get End Property Public Overrides ReadOnly Property ButtonPressedGradientEnd() _ As System.Drawing.Color Get Return Color.Green End Get End Property Public Overrides ReadOnly Property ButtonSelectedGradientBegin() _ As Color Get Return Color.Yellow End Get End Property Public Overrides ReadOnly Property ButtonSelectedGradientMiddle() As System.Drawing.Color Get Return Color.Orange End Get End Property Public Overrides ReadOnly Property ButtonSelectedGradientEnd() _ As System.Drawing.Color Get Return Color.Violet End Get End Property End Class ``` ### To change the rendering for all ToolStrip controls in your application 1. Use the property to choose one of the provided renderers. 2. Use to assign a custom renderer. 3. Ensure that is set to the default value of . ### To turn off the Microsoft Office colors for the entire application - Set to `false`. ### To turn off the Microsoft Office colors for one ToolStrip control - Use code similar to the following code example. ```vb Dim colorTable As ProfessionalColorTable() colorTable.UseSystemColors = True Dim toolStrip.Renderer As ToolStripProfessionalRenderer(colorTable) ``` ```csharp ProfessionalColorTable colorTable = new ProfessionalColorTable(); colorTable.UseSystemColors = true; toolStrip.Renderer = new ToolStripProfessionalRenderer(colorTable); ``` ## See also - - - - [Controls with Built-In Owner-Drawing Support](controls-with-built-in-owner-drawing-support.md) - [How to: Create and Set a Custom Renderer for the ToolStrip Control in Windows Forms](create-and-set-a-custom-renderer-for-the-toolstrip-control-in-wf.md) - [ToolStrip Control Overview](toolstrip-control-overview-windows-forms.md)