Toolstrip and Case of Extra Line

I needed up/down buttons for one program of mine and I decided to have them on ToolStrip control.

As soon as I figured how to make it vertical, I stumbled upon shade issues. In default RenderMode (ManagerRenderMode) background is just little bit of different background color. Usually this does not matter since ToolStrip is docked on form but in this situation it was quite visible. Solution was simple - switch RenderMode to System and control blends in perfectly.

However, using System render mode has one downfall. There is small light 3D line on bottom of control. Although it is not visible too much, it was enough to bother me.

Since System rendering is done via ToolStripSystemRenderer class, first idea was to extend it. And there it was - OnRenderToolStripBorder. It is enough to override this method and border is never created:

class ToolStripBorderlessSystemRenderer : ToolStripSystemRenderer {

protected override void OnRenderToolStripBorder(ToolStripRenderEventArgs e) {
//base.OnRenderToolStripBorder(e);
}

}

Only thing left is to actually telling ToolStrip to use our class for rendering:

SettingsForm() {
InitializeComponent();
toolstripVhdOrder.Renderer = new ToolStripBorderlessSystemRenderer();
}

Leave a Reply

Your email address will not be published. Required fields are marked *