I\'m using OwnerDrawFixed
as a DrawMode for the custom ListBox control in my WinForms app.
I want to repaint the background (or do some other action) of
This solution will just weigh your code down; just try this:
If e.State And DrawItemState.Selected Then
e.Graphics.FillRectangle(SystemBrushes.HotTrack, e.Bounds)
e.Graphics.DrawString(drv, Me.Font, SystemBrushes.HighlightText, e.Bounds.X + 18, e.Bounds.Y + 1)
Else
e.Graphics.FillRectangle(SystemBrushes.Window, e.Bounds)
e.Graphics.DrawString(drv, Me.Font, SystemBrushes.ControlText, e.Bounds.X + 18, e.Bounds.Y + 1)
End If
This operation: e.State And DrawItemState.Selected
verifies the item is hovered. No need to put a whole pack of code just to know what item is hovered.