views:

45

answers:

2

I'm working on an application in which a list view is used to select what set of data to display. When the user clicks a list item, the main view updates with the data associated with the selected item, and the ListView control loses focus. Upon losing focus, the control stops highlighting the selected item even though I've explicitly set HideSelection to false.

According to MSDN: "true if the selected item does not appear highlighted when the control loses focus; false if the selected item still appears highlighted when the control loses focus. The default is true."

Is this a bug, or am I missing something? We are using .NET version 2.0. (Yes, I've checked that the property isn't set anywhere outside of the designer-generated code)


Edit: Apparently the selection was highlighted, albeit very subtly. After looking through the list of properties I don't see a way to change the highlighting color when the control doesn't have focus. Any ideas? Thanks.

+2  A: 

Are you sure it isn't just really, really hard to see. On my screen the difference is white vs "really really pale grey" - very subtle. It is more obvious if you change the ListView's background colour while you investigate (also, try turning down your VDU brightness).

Shown below; the "def" is actually selected.

No, really it is

Marc Gravell
Hah, you're right! When I looked at my monitor from a different angle it appeared quite clearly. How silly. I don't suppose you know of a way to change the color of the selection when the control doesn't have focus?
Martin Törnwall
@Martin - no, I don't; sorry.
Marc Gravell
@Marc: I might have to resort to some form of custom rendering, then. Thanks anyway -- you saved me many a headache trying to figure out why it wasn't showing up! :)
Martin Törnwall
I'll accept your solution as it answers my original question, and because it seems that there is no way of accomplishing what I'm trying to do without customizing the rendering of the ListView. Thanks for your help.
Martin Törnwall
+1  A: 

Some LCD monitors do indeed have a problem showing the gray color distinctive enough. It is a system setting and affects all programs, you cannot change it for just your own. Given that this really a problem with your monitor, there's little reason to not just fix it by changing the system color.

Use Control Panel + Display. On Win7 click Personalization, Window Color, Advanced Appearance Settings. Select "Disabled Item" in the dialog.

Hans Passant
Interestingly, that changed the appearance of essentially *every* inactive control but the list view. I'm stuck with a localized Windows version, so I might have picked the wrong setting.
Martin Törnwall