I've got a combobox control which I've set to "Drop Down List" style (because I don't want the user to be able to type text in the combobox). Only probably is that I don't like the way that the "Drop Down List" style looks, so I'm trying to change it to where it looks like the normal combobox style.
So I set the draw mode to "owner draw fixed". My goal is to have a white background / black text for the combobox items that are not hovered over, and a blue background / white text for the items that are hovered over (just like a normal combobox would look).
The background colors are working as desired, but the text colors are not (the text is staying black, even on items that are hovered over).
Here is my code...
Private Sub ComboBox1_DrawItem_1(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DrawItemEventArgs) Handles ComboBox1.DrawItem
Dim TextBrush As Brush
If (e.State And DrawItemState.HotLight) = DrawItemState.HotLight Then
TextBrush = Brushes.White
Else
TextBrush = Brushes.Black
End If
Dim index As Integer = If(e.Index >= 0, e.Index, 0)
e.DrawBackground()
e.Graphics.DrawString(ComboBox1.Items(index).ToString(), e.Font, TextBrush, e.Bounds, StringFormat.GenericDefault)
e.DrawFocusRectangle()
End Sub
Any ideas?
I've been searching Google for a couple hours for the solution, but no luck so far.