How to disable the line under tool strip in winform c#?

monkey_boys picture monkey_boys · Dec 16, 2009 · Viewed 14.6k times · Source

alt text

this line ?     

Answer

sgoldyaev picture sgoldyaev · Jan 13, 2010

It's a bug in the "system" renderer, details in this bug report.

Microsoft's response gives a very easy workaround:

1) Create a subclass of ToolStripSystemRenderer, overriding OnRenderToolStripBorder and making it a no-op:

public class MySR : ToolStripSystemRenderer
{
    public MySR() { }

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

2) Use that renderer for your toolstrip. The renderer must be assigned after any assignment to the toolstrip's RenderMode property or it will be overwritten with a reference to a System.Windows.Forms renderer.

toolStrip3.Renderer = new MySR();