|
Imports System.Drawing.Drawing2D
Public Class uComboBox
Inherits ComboBox
Public Sub New()
DrawMode = DrawMode.OwnerDrawFixed
End Sub
Protected Overrides Sub OnDrawItem(ByVal e As DrawItemEventArgs)
Dim strText As String = CStr(Items.Item(e.Index))
Dim brBrush As Brush
If CBool(e.State And DrawItemState.Selected) Then
brBrush = New LinearGradientBrush( _
e.Bounds, Color.Blue, Color.Yellow, 0)
Else
If e.Index Mod 2 = 0 Then
brBrush = New LinearGradientBrush( _
e.Bounds, Color.Yellow, Color.Red, 0)
Else
brBrush = New LinearGradientBrush( _
e.Bounds, Color.Red, Color.Yellow, 0)
End If
End If
e.Graphics.FillRectangle(brBrush, e.Bounds)
brBrush = New SolidBrush(e.ForeColor)
e.Graphics.DrawString(strText, e.Font, brBrush, _
e.Bounds.Left, e.Bounds.Top)
End Sub
End Class
|
|