Don't turn SelectedListviewItem gray when losing focus
Hi!
If someone is still wondering (and I didn't find one satisfying answer anywhere and setting hideselection=false also didn't work ;) ):
If you don't want your listview to turn the background color of a selected listviewitem to gray when the listview loses focus, then put this into your subclassed listview:
VB Code:
Protected Overrides Sub DefWndProc(ByRef m As System.Windows.Forms.Message)
If Not m.Msg = 8 Then MyBase.DefWndProc(m)
End Sub
As I figure, this traps the message that is responsible for it.
Although I really don't know why it is so difficult to find a list of all the messages (and their relating codes) on the net (and I didn't find that one, too)
Anyhow, that works for me now :)
Regards!
Re: Don't turn SelectedListviewItem gray when losing focus
wouldn't it be hideselection=true for what you wanted to do?
Re: Don't turn SelectedListviewItem gray when losing focus
Yes, it would work but if you wanted the selection to remain then it wont. Isnt there a Ghosted property that
you can set the color of and maybe duplicate the selected color.
Re: Don't turn SelectedListviewItem gray when losing focus
If I turn hideselection=true then the highlighted item turns white when losing focus and you don't see it anymore. When hideselection=false then it just turns to gray.
Also, I didn't find a way to set the background color of a selected item without making item.selected=false because otherwise some mechanism sets the background color of an item to that default selection blue as long as it is selected.
And if I deselect the selected item and then set the background color to another one than the default, the the listviewitems flicker everytime you click on an item.
Wasn't able to handle this, yet...