Removing white border on a ToolStrip
If you have ever used the ToolStrip control and changed its background colour, you will have noticed that it has a white border around it as show in the picture. This problem can be overcome with a simple override.
Create a new file ToolStripOverride.cs and copy the following code.
1 2 3 4 5 6 7 8 9 10 11 | using System.Windows.Forms; namespace OverrideControls { public class ToolStripOverride : ToolStripProfessionalRenderer { public ToolStripOverride() { } protected override void OnRenderToolStripBorder(ToolStripRenderEventArgs e) { } } } |
Then inside the class where you have your ToolStrip control add the following line to the constructor.
1 | myToolStripControl.Renderer = new ToolStripOverride(); |
Tags: .Net, C#, Controls, ToolStrip, Visual Studio
Simple and straight to the point… and most importantly the solution worked as is. Thanks.
Thank’s a lot!! :)
gr8 on thanks bro. simple and cut to the point.
Any way to get this working on VB.NET 2010?
Hi Knuckles,
The same can be achieved using Visual Basic .NET. I have tested it and confirmed it works.
If you are not sure how to translate the code to .Net use one of the websites that can translate C# to .Net.
First create the class ToolStripOverride. Then inside your Form1_Load you write something like ToolStrip1.Renderer = New OverrideControls.ToolStripOverride()