Hey there,
When trying to implement custom background painting in a ToolStrip control (System.Windows.Forms.ToolStrip), I find myself having to add a bit of hack design. When the ToolStrip control's RenderMode property is System, there is always a grey line drawn at the bottom edge of the control. When RenderMode is instead set to Professional, there is a blueish thinner rounded line at the bottom and right edges.
When trying to implement custom background painting in a ToolStrip control (System.Windows.Forms.ToolStrip), I find myself having to add a bit of hack design. When the ToolStrip control's RenderMode property is System, there is always a grey line drawn at the bottom edge of the control. When RenderMode is instead set to Professional, there is a blueish thinner rounded line at the bottom and right edges.
These lines seem to be drawn after the overridden OnPaint method and I can't get the lines to disappear without adding a bit of hack code.
The ugly solution: I put the ToolStrip control within a Panel, set both controls' AutoSize property to False and derived a new class from LayoutEngine to "manually" resize the controls so that the ToolStrip always is a couple of pixels higher than the Panel. (Badness, badness!!!) Using a Padding.Bottom value of 2 for the ToolStrip control, the ToolStrip contents look as usual, my painting code in the overridden OnPaint method works fine, and the grey line is clipped out by the slightly smaller Panel control.
This is NOT good practice, I know, and I'd love to do this "the right way" instead, but I just can't think of another way of doing this.
Does anybody have a suggestion for me Please
Does anybody have a suggestion for me Please

Overriding OnPaint in ToolStrip
Jon vdB
Jerry017
ToolStrip.Renderer = new MyFancyRenderer();
public class MyFancyRenderer : ToolStripProfessionalRenderer {
protected override OnRenderToolStripBorder(ToolStripItemRenderEventArgs e) {
// dont call base.
}
}
More samples:
http://msdn2.microsoft.com/en-us/library/ms181005