locked
custom context menu?? RRS feed

  • Question

  • Hi,

        Can somebody guide me how to draw custom color(gradient color)  for mouse over on the menu of the context menu in winform?

        i am trying to get vista effect.

     

    Thanks.

    Monday, April 12, 2010 12:13 PM

Answers

  • If you are looking to have a Gradient Background in the context menu then following code can be used in Paint event of ContextMenu

     
    Private Sub ContextMenuStrip1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles ContextMenuStrip1.Paint
            Dim Gradient_Brush As New Drawing2D.LinearGradientBrush(e.ClipRectangle, Color.SteelBlue, Color.LightSteelBlue, 45)
            e.Graphics.FillRectangle(Gradient_Brush, e.ClipRectangle)
        End Sub

    Gaurav Khanna
    • Marked as answer by Aland Li Thursday, April 15, 2010 5:36 AM
    Monday, April 12, 2010 2:33 PM

All replies

  • What vista effect do you mean? And do you mean the system menu (left click the icon on top-left of the window)?


    var Sebastian_Brand = { My_blog, Lictivate_Licensing_and_activation_service, Windows_Installer_and_WiX_tools, Outlook_add-ins }
    Monday, April 12, 2010 1:52 PM
  • If you are looking to have a Gradient Background in the context menu then following code can be used in Paint event of ContextMenu

     
    Private Sub ContextMenuStrip1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles ContextMenuStrip1.Paint
            Dim Gradient_Brush As New Drawing2D.LinearGradientBrush(e.ClipRectangle, Color.SteelBlue, Color.LightSteelBlue, 45)
            e.Graphics.FillRectangle(Gradient_Brush, e.ClipRectangle)
        End Sub

    Gaurav Khanna
    • Marked as answer by Aland Li Thursday, April 15, 2010 5:36 AM
    Monday, April 12, 2010 2:33 PM