C # ToolStrip transparent but border still visible?

I have a ToolStrip in a C # application in which I set the background color to Transparent. This shows the foreground color of the form, but unfortunately the ToolStrip border is still visible.

I implemented Custom Renderer and redefined the DrawBoarder method to not draw anything, but it seems to be applicable to all buttons contained in it (i.e. the menu on the drop-down buttons is also drawn without a frame).

So I'm stuck. What is the best way to make the entire ToolStrip transparent, but leave the buttons alone?

+4
source share
3 answers
protected override void OnRenderToolStripBorder(ToolStripRenderEventArgs e) { if( e.ToolStrip.GetType().Name != "MyCustomToolStrip" ) { base.OnRenderToolStripBorder(e); } } 
+2
source

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

 public class TestStripRenderer : ToolStripProfessionalRenderer { protected override void OnRenderToolStripBorder(ToolStripRenderEventArgs e) { } } 
+4
source

Since you are trying to hide the toolbar, but save it, I have to set it.

Do you even need a toolbar?

Perhaps it would be better if you just used buttons in an application without a visible unnecessary toolbar.

0
source

Source: https://habr.com/ru/post/1342994/


All Articles