How to prevent Backcolor and forecolor change in MenuBar Dropdowns On click

Viewed 51

This is menubar dropdown 1

This is the Menubar Dropdown

We know the background is

Color.FromARGB(61,61,61)

Foreground = Color.Purple

When it is clicked it looks like:

After

I would like to prevent it from changing the Backcolor and when I put my mouse over an option in runtime it also changes the backcolor. I tried adding an onclick sub that keeps the backcolor after it was clicked but it still changed.

1 Answers

According to this answer in c#, you can use a ToolStripProfessionalRenderer to override certain properties of the menu.

Public Class Form1
    Public Sub New()
        ' This call is required by the designer.
        InitializeComponent()
        ' Add any initialization after the InitializeComponent() call.
        MenuStrip1.Renderer = New MyRenderer()
    End Sub
    Private Class MyRenderer
        Inherits ToolStripProfessionalRenderer
        Public Sub New()
            MyBase.New(New MyColors())
        End Sub
        Private Class MyColors
            Inherits ProfessionalColorTable
            Public Overrides ReadOnly Property MenuItemPressedGradientBegin As Color
                Get
                    Return Color.FromArgb(61, 61, 61)
                End Get
            End Property
            Public Overrides ReadOnly Property MenuItemPressedGradientEnd As Color
                Get
                    Return Color.FromArgb(61, 61, 61)
                End Get
            End Property
            Public Overrides ReadOnly Property MenuItemSelectedGradientBegin As Color
                Get
                    Return Color.FromArgb(61, 61, 61)
                End Get
            End Property
            Public Overrides ReadOnly Property MenuItemSelectedGradientEnd As Color
                Get
                    Return Color.FromArgb(61, 61, 61)
                End Get
            End Property
            Public Overrides ReadOnly Property MenuItemSelected As Color
                Get
                    Return Color.FromArgb(61, 61, 61)
                End Get
            End Property
        End Class
    End Class
End Class

enter image description here

Related