Removing white border on a ToolStrip
Sunday, March 8th, 2009If 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(); |