override menu drawing?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

hi, im making my own menustrip control since i want to add a few things to
it. but now im stuck on how when you click on for instance a main node of
"File", it always is highlighted in one color....i cant figure out how to
change this, be it on the normal one or how to override this by making my
own....any help would be great
 
hi, im making my own menustrip control since i want to add a few things to
it. but now im stuck on how when you click on for instance a main node of
"File", it always is highlighted in one color....i cant figure out how to
change this, be it on the normal one or how to override this by making my
own....any help would be great


When I want to customize a MenuStrip, ToolStrip,or StatusStrip, I use
the ToolStripProfessionalRenderer class which has a number of
properties that can be assigned custom colors for all of the above.
This example produces a SlateGray gradient when the cursor is over a
MenuItem:

Public Sub New()
' This call is required by the Windows Form Designer.
InitializeComponent()
ToolStripManager.Renderer = New _
ToolStripProfessionalRenderer _
(New CustomProfessionalColors())
End Sub


Public Class CustomProfessionalColors
Inherits ProfessionalColorTable

Public Overrides ReadOnly Property MenuItemSelectedGradientBegin()
_ As System.Drawing.Color
Get
Return Color.White
End Get
End Property
Public Overrides ReadOnly Property MenuItemSelectedGradientEnd() _
As System.Drawing.Color
Get
Return Color.SlateGray
End Get
End Property

Public Overrides ReadOnly Property MenuItemBorder() _
As System.Drawing.Color
Get
Return Color.MidnightBlue
End Get
End Property

End Class

The above is only valid on target systems with VisualStyles enabled.


Gene
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top