4

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?

E.Beach
  • 1,829
  • 2
  • 22
  • 34

3 Answers3

5

I have tried just overriding the OnRenderToolStripBorder method and it seems it doesn't affect the buttons at all. Have you tried it like this?

public class TestStripRenderer : ToolStripProfessionalRenderer
{   
    protected override void OnRenderToolStripBorder(ToolStripRenderEventArgs e)
    {
    }
}
Darko Kenda
  • 4,781
  • 1
  • 28
  • 31
  • If you add a dropdown button to the toolbar, does the dropdown button's menu render with or without a border? On my system this code removes the toolstrip's border and the drop down menu's border – E.Beach Mar 09 '11 at 14:26
  • The dropdown menu appears to be rendered exactly the same with or without this custom renderer. – Darko Kenda Mar 09 '11 at 21:21
2
protected override void OnRenderToolStripBorder(ToolStripRenderEventArgs e)
{
    if( e.ToolStrip.GetType().Name != "MyCustomToolStrip" )
    {
        base.OnRenderToolStripBorder(e);
    }
}
John Arlen
  • 6,539
  • 2
  • 33
  • 42
0

Since you are trying to make the toolstrip hidden but keep the buttons, I have to put this out there.

Do you even need the toolstrip?

It might be better if you just used buttons in the application without the seemingly unneeded toolstrip.

Tony Abrams
  • 4,505
  • 3
  • 25
  • 32