Hi,
Here is an example.
Dim arColor() As String
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
ComboBox1.DrawMode = DrawMode.OwnerDrawFixed
ComboBox1.Location = New Point(60, 60)
ComboBox1.Width = 150
ComboBox1.Visible = True
ComboBox1.DropDownStyle = ComboBoxStyle.DropDownList
arColor = KnownColor.GetNames(GetType(KnownColor))
ComboBox1.Items.AddRange(arColor)
End Sub
Private Sub combobox1_DrawItem(ByVal sender As Object, ByVal e As
System.Windows.Forms.DrawItemEventArgs) Handles ComboBox1.DrawItem
Dim g As Graphics = e.Graphics
Dim s As String
Dim d As Date
Dim br As Brush = SystemBrushes.WindowText
Dim brBack As Brush
Dim rDraw As Rectangle
Dim bSelected As Boolean = CBool(e.State And DrawItemState.Selected)
Dim bValue As Boolean = CBool(e.State And
DrawItemState.ComboBoxEdit)
rDraw = e.Bounds
rDraw.Inflate(-1, -1)
If bSelected And Not bValue Then
brBack = Brushes.LightBlue
g.FillRectangle(Brushes.LightBlue, rDraw)
g.DrawRectangle(Pens.Blue, rDraw)
Else
brBack = Brushes.White
g.FillRectangle(brBack, e.Bounds)
End If
br = Nothing
brBack = Nothing
rDraw = Nothing
Try
s = ComboBox1.Items.Item(e.Index).ToString
Catch
s = ""
End Try
Dim x, y As Integer
x = e.Bounds.Left + 25
y = e.Bounds.Top + 1
Dim c As Color
Dim b As SolidBrush
c = Color.FromName(s)
b = New SolidBrush(c)
g.FillRectangle(b, x - 20, y + 2, 10, 10)
g.DrawString(s, ComboBox1.Font, Brushes.Black, x, y)
End Sub
Ken