@RodFromGermany Sorry
VB.NET-Quellcode
- Public Class MyComboBox : Inherits ComboBox
- #Region " Funktionen & Events "
- Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
- MyBase.OnPaint(e)
- ' DrawString Parameter
- Dim y As Integer = CInt(e.Graphics.MeasureString(Text, Font).Height / 2)
- Dim x As Integer = CInt(e.Graphics.MeasureString(Text, Font).Width)
- Dim cmbRect As Rectangle = New Rectangle(0, 0, Width, Height)
- ' DropDownIcon Parameter
- Dim Px As Integer = Width - 6
- Dim Py As Integer = CInt(Height / 2 - 3)
- ' Points für das Dreieck
- Dim P1 As New Point(Px, Py)
- Dim P2 As New Point(Px - 12, Py)
- Dim P3 As New Point(Px - 6, Py + 6)
- Dim PolyP() As Point = {P1, P2, P3}
- e.Graphics.FillRectangle(Brushes.White, cmbRect)
- e.Graphics.DrawRectangle(New Pen(CT.BorderColor), 0, 0, Width - 1, Height - 1)
- e.Graphics.FillPolygon(New SolidBrush(CT.BorderColor), PolyP)
- If Me.Focused Then
- e.Graphics.FillPolygon(New SolidBrush(CT.ControlSelectColor), PolyP)
- End If
- e.Graphics.DrawString(Text, Font, New SolidBrush(ForeColor), New Point(2, CInt(Height / 2 - y)))
- End Sub
- Protected Overrides Sub OnDrawItem(e As DrawItemEventArgs)
- MyBase.OnDrawItem(e)
- SetTheme(Themes)
- e.Graphics.DrawString(MyBase.Items(e.Index).ToString, Font, New SolidBrush(ForeColor), New Point(e.Bounds.X, CInt(e.Bounds.Y / 2)))
- End Sub
- Sub New()
- MyBase.New
- MyBase.FlatStyle = FlatStyle.Flat
- MyBase.Font = New Font("Verdana", 9, FontStyle.Regular)
- Me.SetStyle(ControlStyles.OptimizedDoubleBuffer, True)
- Me.SetStyle(ControlStyles.UserPaint, True)
- Me.DropDownStyle = ComboBoxStyle.DropDownList
- End Sub
- Private Sub MyComboBox_Enter(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Enter
- Invalidate()
- End Sub
- Private Sub MyComboBox_Leave(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Leave
- Invalidate()
- End Sub
- Private Sub MyComboBox_Resize(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Resize
- Invalidate()
- End Sub
- #End Region
- End Class
.wife {right: 100%; margin: 0;}