Flat combobox

a_jam_sandwich

Junior Contributor
Joined
Dec 10, 2002
Messages
367
Location
Uk
Right the following code works to a point.
Visual Basic:
    Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
        MyBase.WndProc(m)
        Select Case m.Msg
            Case &HF
                Dim e As Graphics = Me.CreateGraphics
                Dim bgBrush As New SolidBrush(Me.BackColor)
                Dim boxBrush As New SolidBrush(SystemColors.Control)
                Dim arrowBrush As New SolidBrush(Color.Black)
                Dim arrowBrushSelected As New SolidBrush(SystemColors.Highlight)
                e.FillRectangle(bgBrush, e.ClipBounds)

                Dim rect As Rectangle = New Rectangle(Me.Width - 19, 3, 15, Me.Height - 6)
                e.FillRectangle(boxBrush, rect)

                Dim pth As Drawing2D.GraphicsPath = New Drawing2D.GraphicsPath()
                Dim TopLeft As PointF = New PointF(Me.Width - 16, (Me.Height - 5) / 2)
                Dim TopRight As PointF = New PointF(Me.Width - 8, (Me.Height - 5) / 2)
                Dim Bottom As PointF = New PointF(Me.Width - 12, (Me.Height + 2) / 2)
                pth.AddLine(TopLeft, TopRight)
                pth.AddLine(TopRight, Bottom)
                e.SmoothingMode = Drawing2D.SmoothingMode.AntiAlias
                e.FillPath(arrowBrush, pth)
                ControlPaint.DrawBorder(e, ClientRectangle, Color.Black, ButtonBorderStyle.Solid)
        End Select
    End Sub

Looks great but when changing combobox.text to a text item in the list it will not be visable unless the control gets focus and you pull the dropdown down.

Any ideas?


Andy
 
Doesn't matter figured it out

The above will draw untill selected and out of focus after that the
drawitem draws
 
Back
Top