Menüs optisch anpassen

  • VB.NET
  • .NET (FX) 4.0

Es gibt 7 Antworten in diesem Thema. Der letzte Beitrag () ist von Gelöschter Benutzer.

    Was hast du denn bisher schon als Codebasis?

    Edit: Hab mir grad eine Anleitung zu dem Context Menu Tray Icon durchgelesen und glaube, dass das sich lösen lässt, wenn du einfach hinter den Einträgen, bei denen du den Pfeil haben willst, einfach noch ein paar mehr Einträge (Untereinträge) dahinter packst.

    Edit2: codeproject.com/Articles/20775…y-with-Context-Menu-Using

    Lg Radinator
    In general (across programming languages), a pointer is a number that represents a physical location in memory. A nullpointer is (almost always) one that points to 0, and is widely recognized as "not pointing to anything". Since systems have different amounts of supported memory, it doesn't always take the same number of bytes to hold that number, so we call a "native size integer" one that can hold a pointer on any particular system. - Sam Harwell

    Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von „Radinator“ ()

    Sorry ich habe Visual Basic. Ist auch nicht so wichtig. Ich werde noch mal paar Tage probieren.
    Die weißen Pfeile würden sich echt gut machen im Programm. Wäre echt toll, wenn Ihr mir noch weiter helfen könntet.

    VB.NET-Quellcode

    1. Public Class ContextColorTable
    2. Inherits ProfessionalColorTable
    3. Public Overrides ReadOnly Property ToolStripBorder() As System.Drawing.Color
    4. Get
    5. Return ColorMenuLight
    6. End Get
    7. End Property
    8. Public Overrides ReadOnly Property MenuItemBorder() As System.Drawing.Color
    9. Get
    10. Return ColorMenuLight
    11. End Get
    12. End Property
    13. Public Overrides ReadOnly Property MenuBorder() As System.Drawing.Color
    14. Get
    15. Return Color.White
    16. End Get
    17. End Property
    18. Public Overrides ReadOnly Property MenuItemSelected() As System.Drawing.Color
    19. Get
    20. Return ColorMenuLight
    21. End Get
    22. End Property
    23. Public Overrides ReadOnly Property ButtonSelectedBorder() As System.Drawing.Color
    24. Get
    25. Return ColorMenuLight
    26. End Get
    27. End Property
    28. Public Overrides ReadOnly Property Separatorlight() As System.Drawing.Color
    29. Get
    30. Return Color.White
    31. End Get
    32. End Property
    33. Public Overrides ReadOnly Property Separatordark() As Color
    34. Get
    35. Return Color.White
    36. End Get
    37. End Property
    38. Public Overrides ReadOnly Property CheckBackground() As System.Drawing.Color
    39. Get
    40. Return Color.White
    41. End Get
    42. End Property
    43. Public Overrides ReadOnly Property CheckPressedBackground() As System.Drawing.Color
    44. Get
    45. Return ColorMenu
    46. End Get
    47. End Property
    48. Public Overrides ReadOnly Property CheckSelectedBackground() As System.Drawing.Color
    49. Get
    50. Return Color.White
    51. End Get
    52. End Property
    53. Public Overrides ReadOnly Property ImageMarginGradientBegin() As System.Drawing.Color
    54. Get
    55. Return ColorMenuLight
    56. End Get
    57. End Property
    58. Public Overrides ReadOnly Property ImageMarginGradientMiddle() As System.Drawing.Color
    59. Get
    60. Return ColorMenu
    61. End Get
    62. End Property
    63. Public Overrides ReadOnly Property ImageMarginGradientEnd() As System.Drawing.Color
    64. Get
    65. Return ColorMenu
    66. End Get
    67. End Property
    68. End Class

    Dieser Beitrag wurde bereits 3 mal editiert, zuletzt von „Gelöschter Benutzer“ ()

    codeconverter.sharpdevelop.net/SnippetConverter.aspx :love:

    VB.NET-Quellcode

    1. Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    2. MenuStrip1.Renderer = New WhiteArrowRenderer()
    3. End Sub
    4. Public Class WhiteArrowRenderer
    5. Inherits ToolStripProfessionalRenderer
    6. Protected Overrides Sub OnRenderArrow(e As ToolStripArrowRenderEventArgs)
    7. Dim tsMenuItem = TryCast(e.Item, ToolStripMenuItem)
    8. If tsMenuItem IsNot Nothing Then
    9. e.ArrowColor = Color.White
    10. End If
    11. MyBase.OnRenderArrow(e)
    12. End Sub
    13. End Class
    Habe es hinbekommen mit eurer Hilfe. Vielen Dank! Alle Menüs werden mit einer benutzerdefinierten Farbe einschließlich der Pfeile (für vorhandene untergeordnete Menüeinträge) dargestellt


    Aufruf

    VB.NET-Quellcode

    1. MenuStrip1.Renderer = New TSRenderer(SetContextColor)


    Quellcode

    VB.NET-Quellcode

    1. Public SetContextColor As ContextColorTable
    2. Public Class TSRenderer
    3. Inherits ToolStripProfessionalRenderer
    4. Protected Overrides Sub OnRenderArrow(e As ToolStripArrowRenderEventArgs)
    5. Dim tsMenuItem = TryCast(e.Item, ToolStripMenuItem)
    6. If tsMenuItem IsNot Nothing Then
    7. e.ArrowColor = Color.White
    8. End If
    9. MyBase.OnRenderArrow(e)
    10. End Sub
    11. Public Sub New(ByVal PCT As ProfessionalColorTable)
    12. MyBase.New(PCT)
    13. PCT = SetContextColor
    14. End Sub
    15. End Class
    16. Public Class ContextColorTable
    17. Inherits ProfessionalColorTable
    18. Public Overrides ReadOnly Property ToolStripBorder() As System.Drawing.Color
    19. Get
    20. Return ColorMenuLight
    21. End Get
    22. End Property
    23. Public Overrides ReadOnly Property MenuItemBorder() As System.Drawing.Color
    24. Get
    25. Return ColorMenuLight
    26. End Get
    27. End Property
    28. Public Overrides ReadOnly Property MenuBorder() As System.Drawing.Color
    29. Get
    30. Return Color.White
    31. End Get
    32. End Property
    33. Public Overrides ReadOnly Property MenuItemSelected() As System.Drawing.Color
    34. Get
    35. Return ColorMenuLight
    36. End Get
    37. End Property
    38. Public Overrides ReadOnly Property ButtonSelectedBorder() As System.Drawing.Color
    39. Get
    40. Return ColorMenuLight
    41. End Get
    42. End Property
    43. Public Overrides ReadOnly Property Separatorlight() As System.Drawing.Color
    44. Get
    45. Return Color.White
    46. End Get
    47. End Property
    48. Public Overrides ReadOnly Property Separatordark() As Color
    49. Get
    50. Return Color.White
    51. End Get
    52. End Property
    53. Public Overrides ReadOnly Property CheckBackground() As System.Drawing.Color
    54. Get
    55. Return Color.White
    56. End Get
    57. End Property
    58. Public Overrides ReadOnly Property CheckPressedBackground() As System.Drawing.Color
    59. Get
    60. Return ColorMenu
    61. End Get
    62. End Property
    63. Public Overrides ReadOnly Property CheckSelectedBackground() As System.Drawing.Color
    64. Get
    65. Return Color.White
    66. End Get
    67. End Property
    68. Public Overrides ReadOnly Property ImageMarginGradientBegin() As System.Drawing.Color
    69. Get
    70. Return ColorMenuLight
    71. End Get
    72. End Property
    73. Public Overrides ReadOnly Property ImageMarginGradientMiddle() As System.Drawing.Color
    74. Get
    75. Return ColorMenu
    76. End Get
    77. End Property
    78. Public Overrides ReadOnly Property ImageMarginGradientEnd() As System.Drawing.Color
    79. Get
    80. Return ColorMenu
    81. End Get
    82. End Property
    83. End Class

    Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von „Gelöschter Benutzer“ ()