WinForms ListView.HideSelection property has no effect?
I'm working on an a开发者_开发问答pplication 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.
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.
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.
精彩评论