Search code examples
c#.netdrawingtoolstrip

C# ToolStrip is transparent but border is still visible?


I have a ToolStrip in a C# application that I set the background color to Transparent. This reveals the underlying form's color but unfortunately the ToolStrip border is still visible.

I've implemented a Custom Renderer and overridden the DrawBoarder method to not draw anything but that seems to apply to all of the contained buttons as well (i.e the menu on drop down buttons are also drawn without a border).

So I'm stuck. What's the best way to draw transparent the entire ToolStrip but leave the buttons alone?


Solution

  • protected override void OnRenderToolStripBorder(ToolStripRenderEventArgs e)
    {
        if( e.ToolStrip.GetType().Name != "MyCustomToolStrip" )
        {
            base.OnRenderToolStripBorder(e);
        }
    }