首页 > 解决方案 > 更改组合框自动完成下拉列表的颜色

问题描述

我制作了一个自定义组合框用户控件。主要目的是在黑暗模式下渲染它。我已经设法实现了大部分。但是,我不知道如何修改自动完成下拉菜单(即应用前后颜色)。

这是问题所在:

在此处输入图像描述

我正在通过以下代码修改组合框渲染:

Protected Overrides Sub WndProc(ByRef m As Message)
    MyBase.WndProc(m)

    Select Case m.Msg
        Case &HF
            Dim g As Graphics = Me.CreateGraphics

            ' Full Control Background
            g.FillRectangle(_BorderBrush, Me.ClientRectangle)
            If Me.DropDownStyle = ComboBoxStyle.DropDown Then
                g.FillRectangle(New SolidBrush(Me.BackColor), _BorderWidth, _BorderWidth,
                            Me.Width - _ButtonWidth - (3 * _BorderWidth),
                            Me.ClientRectangle.Height - (2 * _BorderWidth))
                ' DropDown Button Background
                Dim rect As Rectangle = New Rectangle(Me.Width - _ButtonWidth - _BorderWidth, _BorderWidth,
                                                  _ButtonWidth, Me.Height - (2 * _BorderWidth))
                g.FillRectangle(_DropButtonBrush, rect)

            ElseIf Me.DropDownStyle = ComboBoxStyle.DropDownList Then
                g.FillRectangle(New SolidBrush(Me.BackColor), _BorderWidth, _BorderWidth,
                            Me.Width - (2 * _BorderWidth),
                            Me.ClientRectangle.Height - (2 * _BorderWidth))
            End If

            ' Drop Down BUtton Arrow
            Dim pth As Drawing2D.GraphicsPath = New Drawing2D.GraphicsPath()
            Dim TopLeft As PointF = New PointF(Me.Width - _ButtonWidth - _BorderWidth + 2, (Me.Height - 5) / 2)
            Dim TopRight As PointF = New PointF(Me.Width - 6, (Me.Height - 5) / 2)
            Dim Bottom As PointF = New PointF(Me.Width - 9, (Me.Height + 2) / 2)
            pth.AddLine(TopLeft, TopRight)
            pth.AddLine(TopRight, Bottom)
            g.SmoothingMode = Drawing2D.SmoothingMode.HighQuality

            g.FillPath(_ArrowBrush, pth)

        Case Else
            Exit Select
    End Select

End Sub

我不完全理解 WndProc 过程,但我想知道是否还有其他代码用于自动完成下拉渲染?但是,不知道如何去寻找这些代码。

有任何想法吗?

标签: .netcomboboxautocompleterendering

解决方案


推荐阅读