blog

I like to blog about current software design and development projects, as well as general everyday news and events. I'm passionate about what I do and you can follow my personal journey through my blog. I'm constantly on the lookout for new development techniques and technologies to keep on top of the changing market, so if I do miss anything feel free to leave me a comment.

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: , , , ,

5 Responses to “Removing white border on a ToolStrip”

  1. Fahad // August 8th, 2009 at 10:53 am

    Simple and straight to the point… and most importantly the solution worked as is. Thanks.

  2. Jan // January 4th, 2012 at 10:40 pm

    Thank’s a lot!! :)

  3. Hsi // March 3rd, 2012 at 8:00 pm

    gr8 on thanks bro. simple and cut to the point.

  4. Knuckles // April 6th, 2012 at 2:56 am

    Any way to get this working on VB.NET 2010?

  5. Beno Gorancic // April 12th, 2012 at 10:18 pm

    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()

Leave a Reply