Click here to Skip to main content
15,891,883 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi

How to Change the menustrip menu item color on mouse hover in vb.net.

Thanks
Sivasankaran G
Posted
Comments
Sergey Alexandrovich Kryukov 25-Oct-12 14:38pm    
What is "in VB.NET"? You need to tag your application type or UI library you want to use. WPF? Forms? Silverlight? Metro? ASP.NET? what?
And what is the problem? Why not simply read MSDN help article on the component involved and see what's available? Tried anything?
--SA
Gssankar 3-Dec-12 0:47am    
Hi SA,

Changes in MDIParent FORM.

Agree with SA, if it is web app then use JQuery for same .

Thanks,
Ambesha
 
Share this answer
 
If you are talking about Desktop Application then change RenderMode to System. It will work.
 
Share this answer
 
Comments
saylibh 22-Mar-14 3:05am    
I want to give each menustrip submenu item differnt background color.
How to do it?
To change the menu strip color just open vb.net, create a new windows form application, and on form1 add menu strip, and type in the follow code:
'written by developer: Amar Tufo
Public Class Form1
    Inherits Form
    Public Sub New()
        Try
            ' initialize added component on form1, which is menu strip;
            'note: if you have added any second component alongside menu
            'strip, such as context menu strip just add additional code 
            'line under InitializeComponent(), and it will work;
            InitializeComponent()
            MenuStrip1.Renderer = New MyRenderer()
        Catch ex As Exception

        End Try
    End Sub
    Public Class MyRenderer
        Inherits ToolStripProfessionalRenderer
        Protected Overloads Overrides Sub OnRenderMenuItemBackground(ByVal e As ToolStripItemRenderEventArgs)
            Try
                Dim rc As New Rectangle(Point.Empty, e.Item.Size)
                Dim c As Color = IIf(e.Item.Selected, Color.DodgerBlue, Color.Red)
                Using brush As New SolidBrush(c)
                    e.Graphics.FillRectangle(brush, rc)
                End Using
            Catch ex As Exception

            End Try

        End Sub
    End Class


this part of code must be inserted on form1 alongside menu strip you previously added on form, but it must be added with exception try handling in order to skip any bug or error in your application.
 
Share this answer
 
Comments
Gssankar 8-Nov-12 5:13am    
Thanks a lot

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900