byman64
byman64

Reputation: 29

VB change color border menustrip but from external class

I found the solution here on how change the colors in the menu. My question is related to the above old solution.

I can confirm that the solution worked fine on vb.net 2015 with framework 4.6.2

Color1 and Color 2 are inside the class.

Question is: how I can use Color1 and Color 2 from form_load1?

Let me report here the full code found (there are 2 answer and here is joint)

Public Class ColorTable
Inherits ProfessionalColorTable

Dim Color1 = ColorTranslator.FromHtml("#343D46")
Dim Color2 = ColorTranslator.FromHtml("#424B54")

Public Overrides ReadOnly Property MenuBorder() As Color
    Get
        Return Color1
    End Get
End Property

Public Overrides ReadOnly Property MenuItemSelectedGradientBegin() As Color
    Get
        Return Color2
    End Get
End Property

Public Overrides ReadOnly Property MenuItemSelectedGradientEnd() As Color
    Get
        Return Color2
    End Get
End Property

Public Overrides ReadOnly Property MenuItemSelected() As Color
    Get
        Return Color2
    End Get
End Property

Public Overrides ReadOnly Property MenuItemBorder() As Color
    Get
        Return Color1
    End Get
End Property

Public Overrides ReadOnly Property MenuItemPressedGradientBegin() As Color
    Get
        Return Color2
    End Get
End Property

Public Overrides ReadOnly Property MenuItemPressedGradientEnd() As Color
    Get
        Return Color2
    End Get
End Property
Public Overrides ReadOnly Property SeparatorDark() As Color
    Get
        Return Color1
    End Get
End Property

Public Overrides ReadOnly Property ToolStripDropDownBackground() As Color
    Get
        Return Color1
    End Get
End Property
Public Overrides ReadOnly Property ImageMarginGradientBegin() As System.Drawing.Color
    Get
        Return Color1
    End Get
End Property
Public Overrides ReadOnly Property ImageMarginGradientEnd() As System.Drawing.Color
    Get
        Return Color1
    End Get
End Property
Public Overrides ReadOnly Property ImageMarginGradientMiddle() As System.Drawing.Color
    Get
        Return Color1
    End Get
End Property
End Class

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    Menus.Renderer = New ToolStripProfessionalRenderer(New ColorTable())
End Sub

Upvotes: 0

Views: 140

Answers (0)

Related Questions