Change appearance of RibbonControlAdv ToolStripEx control in WinForms
This article describes how to change the appearance of the ToolStripEx in the WinForms RibbonControlAdv control.
Appearance of the ToolStripEx
The appearance of the ToolStripEx can be customized by the following steps:
1. Create the ColorTable for customization.
2. Apply the ColorTable value to the CustomRenderer class.
3. Then, proceed to assign the Custom Render class to the ToolStripEx renderer.
To create a custom Color Table
By creating the custom ColorTable, you can assign the required color to the Custom Render class. Here, CustomOffice12Colors class is initialized for this purpose.
To apply ColorTable to the Custom Renderer class
Create a custom renderer class with the required ColorTable value applied to it. Here, the Office12ToolStripRenderer class is initialized for this purpose.
To assign the Custom Renderer class to the ToolStripEx
The Renderer property in the ToolStripEx helps you to apply the custom renderer.
C#
// Initializes the custom color table. CustomOffice12Colors customColors = new CustomOffice12Colors(); //Creates renderer with the custom color table. Syncfusion.Windows.Forms.Tools.Office12ToolStripRenderer renderer = new Syncfusion.Windows.Forms.Tools.Office12ToolStripRenderer(customColors); // Applies the custom renderer to the ToolStripEx to customize the appearance. this.toolStripEx1.Renderer = renderer; //Creates the Custom color table. public class CustomOffice12Colors : Syncfusion.Windows.Forms.Tools.Office12ColorTable { //Overrides the CaptionGradientBegin. public override Color CaptionGradientBegin { get { return Color.Gold; } } //Overrides the CaptionGradientEnd. public override Color CaptionGradientEnd { get { return Color.Goldenrod; } } //Overrides the ToolStripGradientBegin. public override Color ToolStripGradientBegin { get { return Color.LightPink; } } //Overrides the ToolStripGradientEnd. public override Color ToolStripGradientEnd { get { return Color.LightGray; } } }
VB
'Initializes the custom color table. Dim customColors As New CustomOffice12Colors() 'Creates the renderer with the custom color table. Dim renderer As New Syncfusion.Windows.Forms.Tools.Office12ToolStripRenderer(customColors) 'Applies the custom renderer to the ToolStripEx to customize the appearance. Me.toolStripEx1.Renderer = renderer 'Creates the Custom color table. Public Class CustomOffice12Colors Inherits Syncfusion.Windows.Forms.Tools.Office12ColorTable 'Overrides the CaptionGradientBegin. Public Overrides ReadOnly Property CaptionGradientBegin() As Color Get Return Color.Gold End Get End Property 'Overrides the CaptionGradientEnd. Public Overrides ReadOnly Property CaptionGradientEnd() As Color Get Return Color.Goldenrod End Get End Property 'Overrides the ToolStripGradientBegin. Public Overrides ReadOnly Property ToolStripGradientBegin() As Color Get Return Color.LightPink End Get End Property 'Overrides the ToolStripGradientEnd. Public Overrides ReadOnly Property ToolStripGradientEnd() As Color Get Return Color.LightGray End Get End Property End Class
Figure 1: Custom color specified for ToolStripEx in WinForms RibbonControlAdv
The appearance of the ToolStripEx can be changed by using the “VisualStyle” property.
If you want to set the Visual Style for the ToolStripEx, you should not set the custom renderer value to the ToolStripEx's Renderer property. Otherwise, even if you set the VisualStyle property, the ToolStripEx will be displayed depending on the custom renderer value.
C#
// Applies the custom renderer to the ToolStripEx to customize the appearance. //this.toolStripEx1.Renderer = renderer; |
VB
'Applies the custom renderer to the ToolStripEx to customize the appearance. 'Me.toolStripEx1.Renderer = renderer |
Figure 2: Default color scheme of the ToolStripEx in WinForms RibbonControlAdv
Figure 3: ToolStripEx is specified with the Metro Style in WinForms RibbonControlAdv
Samples
C#: ToolStripEx_CustomColor_C#
VB: ToolStripEx_CustomColor_VB