views:

569

answers:

1

I need to display a toolstrip directly beneath a menustrip in my application, but setting RenderMode = Professional for each does not give identical results. They both show a background gradient, but not the same one.

Is there some way to use menustrip rendering for the toolstrip, or vice versa? Or can someone advise how best to implement a gradient myself, that I can perform in a sub-classed renderer?

ADDED LATER: Many thanks to nobugz for his answer below. Helpful material is also in this answer.
There's just one more issue -- if I base my custom renderer on the ToolStripProfessionalRenderer and override OnRenderToolstripBackground, I still get curved right-hand corners on my ToolStrip but not on my MenuStrip. Is there some internal logic that provides a different Region for filling by the background renderer? I've turned off (overridden with a do-nothing function) the border renderer.

+1  A: 

I don't see it but can imagine it's a problem. Override the renderer so it uses the same background renderer for both menu items and toolstrip items:

Public Class Form1
    Public Sub New()
        InitializeComponent()
        MenuStrip1.Renderer = New MyRenderer()
    End Sub

    Private Class MyRenderer
        Inherits ToolStripProfessionalRenderer
        Protected Overrides Sub OnRenderItemBackground(ByVal e As ToolStripItemRenderEventArgs)
            MyBase.OnRenderMenuItemBackground(e)
        End Sub
    End Class
End Class
Hans Passant