Wenn ich mir das anschaue..naja, ist ziemlich schlampig programmiert und da könnte man noch einiges verbessern, leider habe ich nur Zeit für einen schnellen Fix, was aber vielleicht eher das ist was du willst
Public Class FlatCombo
Inherits ComboBox
Private BorderPen = New Pen(SystemColors.ControlDarkDark, 1)
Private BorderBrush As Brush = New SolidBrush(SystemColors.Window)
Private ArrowBrush As Brush = New SolidBrush(SystemColors.ControlText)
Private DropButtonBrush As Brush = New SolidBrush(SystemColors.Control)
Private _ButtonColor As Color = SystemColors.Control
Public Property ButtonColor() As Color
Get
Return _ButtonColor
End Get
Set(ByVal Value As Color)
_ButtonColor = Value
DropButtonBrush = New SolidBrush(Me.ButtonColor)
Me.Invalidate()
End Set
End Property
Dim borderWidth As Integer = 1
Protected Overrides Sub WndProc(ByRef m As Message)
MyBase.WndProc(m)
Select Case m.Msg
Case &HF
'Paint the background. Only the borders
'will show up because the edit
'box will be overlayed
Dim g As Graphics = Me.CreateGraphics
'Dim p As Pen = New Pen(Color.White, 2)
g.FillRectangle(BorderBrush, Me.ClientRectangle)
' Draw the border
Debug.WriteLine(Me.ClientRectangle.ToString())
g.DrawRectangle(BorderPen, 0, 0, Me.ClientRectangle.Width - 1, _
Me.ClientRectangle.Height - 1)
'Draw the background of the dropdown button
Dim rect As Rectangle = New Rectangle(Me.Width - 15, 1, 14, _
Me.Height - 2)
g.FillRectangle(DropButtonBrush, rect)
'Create the path for the arrow
Dim pth As Drawing2D.GraphicsPath = New Drawing2D.GraphicsPath
Dim TopLeft As PointF = New PointF(Me.Width - 13, (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
'Determine the arrow's color.
If Me.DroppedDown Then
ArrowBrush = New SolidBrush(SystemColors.HighlightText)
Else
ArrowBrush = New SolidBrush(SystemColors.ControlText)
End If
'Draw the arrow
g.FillPath(ArrowBrush, pth)
Case Else
Exit Select
End Select
End Sub
'Override mouse and focus events to draw
'proper borders. Basically, set the color and Invalidate(),
'In general, Invalidate causes a control to redraw itself.
#Region "Mouse and focus Overrides"
Protected Overrides Sub OnMouseEnter(ByVal e As System.EventArgs)
MyBase.OnMouseEnter(e)
Me.Invalidate()
End Sub
Protected Overrides Sub OnMouseLeave(ByVal e As System.EventArgs)
MyBase.OnMouseLeave(e)
If Me.Focused Then Exit Sub
Me.Invalidate()
End Sub
Protected Overrides Sub OnLostFocus(ByVal e As System.EventArgs)
MyBase.OnLostFocus(e)
Me.Invalidate()
End Sub
Protected Overrides Sub OnSelectedIndexChanged(ByVal e As System.EventArgs)
MyBase.OnSelectedIndexChanged(e)
Me.Invalidate()
End Sub
#End Region
End Class ________
Alle Angaben ohne Gewähr. Keine Haftung für Vorschläge, Tipps oder sonstige Hilfe, falls es schiefgeht, nur Zeit verschwendet oder man sonst nicht zufrieden ist |