I would like to change selection color in a ListView, from a default (blue). I can not adapt any code that I found to my needs.
Here is the code that is closest.
If e.Item.Selected = True Then
e.Graphics.FillRectangle(New SolidBrush(Color.Gray), e.Bounds)
TextRenderer.DrawText(e.Graphics, e.Item.Text, New Font(ListView2.Font, Nothing), New Point(e.Bounds.Left + 3, e.Bounds.Top + 2), Color.White)
Else
e.DrawDefault = True
End If
The main problem is e.Item.Text
part. It doesn't work for multi column listview. Here is the result.
Before selection :
...and after :
Is it possible to preserve values from other columns and still have full row selection?
Thanks.
See Question&Answers more detail:os