listview selected row is light grey when control loses focus, not deep blue
-
When an row in a ListBox is selected, it is highlighted a nice deep blue. If that ListBox loses focus, the ListBox's selected row remains highlighted in blue. However, when a ListView loses focus (and it's HideSelection property is set to false), although the selected rows remain highlighted, the highlight is no longer a nice deep blue but rather a barely visible light grey. Is there a way to change the highlighted color of ListView's selected row when the ListView no longer has focus? Thanks,
Jim Dolson
-
When an row in a ListBox is selected, it is highlighted a nice deep blue. If that ListBox loses focus, the ListBox's selected row remains highlighted in blue. However, when a ListView loses focus (and it's HideSelection property is set to false), although the selected rows remain highlighted, the highlight is no longer a nice deep blue but rather a barely visible light grey. Is there a way to change the highlighted color of ListView's selected row when the ListView no longer has focus? Thanks,
Jim Dolson
The control is using the system colors to paint itself. If you want to change the colors it's using, you'll have to paint the control yourself. C# Custom Paint ListView[^]
A guide to posting questions on CodeProject
How to debug small programs
Dave Kreskowiak -
When an row in a ListBox is selected, it is highlighted a nice deep blue. If that ListBox loses focus, the ListBox's selected row remains highlighted in blue. However, when a ListView loses focus (and it's HideSelection property is set to false), although the selected rows remain highlighted, the highlight is no longer a nice deep blue but rather a barely visible light grey. Is there a way to change the highlighted color of ListView's selected row when the ListView no longer has focus? Thanks,
Jim Dolson
In addition to Dave's answer, it's usually not worth the effort. Unless you use the highlight-color as defined in the system-colors, your blue would default to red on my desktop :) If it's merely to get consistency then do consider the fact that you are adding code that might throw exceptions/have bugs, while the only advantage is color-consistency (one that is still a non-default, and hence, unexpected) If you are letting the user make a selection, then you could consider using checkboxes to indicate the selection.
Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]
-
In addition to Dave's answer, it's usually not worth the effort. Unless you use the highlight-color as defined in the system-colors, your blue would default to red on my desktop :) If it's merely to get consistency then do consider the fact that you are adding code that might throw exceptions/have bugs, while the only advantage is color-consistency (one that is still a non-default, and hence, unexpected) If you are letting the user make a selection, then you could consider using checkboxes to indicate the selection.
Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]
Thank you gentlemen. I've decided to leave the default behavior alone. Jim