jj 14.04.2016 gelbe combobox

This commit is contained in:
JenneJ
2016-04-14 17:09:57 +02:00
parent 8ed70abb9a
commit 4830606cf3
10 changed files with 264 additions and 148 deletions

View File

@@ -0,0 +1,51 @@
Public Class CustomComboBox
Inherits Windows.Forms.ComboBox
Public Sub New()
MyBase.New()
DrawMode = Windows.Forms.DrawMode.OwnerDrawFixed
End Sub
Protected Overrides Sub OnEnabledChanged(e As EventArgs)
'MyBase.OnEnabledChanged(e)
If Me.Enabled Then
Me.DropDownStyle = ComboBoxStyle.DropDown
Else
Me.DropDownStyle = ComboBoxStyle.DropDownList
End If
End Sub
Protected Overrides Sub OnDrawItem(e As DrawItemEventArgs)
Dim g As System.Drawing.Graphics = e.Graphics
Dim rect As Rectangle = e.Bounds
If e.Index >= 0 Then
Dim label As String = Me.Items(e.Index).ToString()
If e.State = (DrawItemState.Disabled Or DrawItemState.NoAccelerator Or DrawItemState.NoFocusRect Or DrawItemState.ComboBoxEdit) Then
' DISABLED STATE
g.FillRectangle(New SolidBrush(System.Drawing.SystemColors.Info), rect)
g.DrawString(label, e.Font, Brushes.Black, rect)
e.DrawFocusRectangle()
ElseIf (e.State = (DrawItemState.NoAccelerator Or DrawItemState.NoFocusRect)) Then
' ITEMS NOT IN FOCUS
g.FillRectangle(New SolidBrush(Color.White), rect)
g.DrawString(label, e.Font, Brushes.Black, rect)
e.DrawFocusRectangle()
Else
' ITEMS IN FOCUS
g.FillRectangle(New SolidBrush(System.Drawing.SystemColors.Highlight), rect)
g.DrawString(label, e.Font, Brushes.White, rect)
e.DrawFocusRectangle()
End If
End If
g.Dispose()
End Sub
End Class