WinForms ListView.HideSelection 属性没有效果?
我正在开发一个应用程序,其中使用列表视图来选择要显示的数据集。当用户单击列表项时,主视图将使用与所选项目关联的数据进行更新,并且 ListView 控件将失去焦点。失去焦点后,即使我已明确将 HideSelection 设置为 false,控件也会停止突出显示所选项目。
根据 MSDN : “如果控件失去焦点时所选项目不突出显示,则为 true;如果控件失去焦点时所选项目仍然突出显示,则为 false。默认值为 true。”
这是一个错误吗?我错过了什么吗?我们正在使用 .NET 2.0 版本。 (是的,我已经检查过该属性没有在设计器生成的代码之外的任何地方设置)
编辑:显然,选择被突出显示了,尽管非常微妙。查看属性列表后,我没有找到在控件没有焦点时更改突出显示颜色的方法。有什么想法吗?谢谢。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
你确定这不仅仅是真的很难看到吗?在我的屏幕上,区别是白色与“非常非常淡的灰色”——非常微妙。如果您在调查时更改
ListView
的背景颜色(另外,尝试调低 VDU 亮度),情况会更明显。如下所示;实际上选择了“def”。
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.
某些液晶显示器确实存在显示灰色颜色不够鲜明的问题。它是一个系统设置,会影响所有程序,您不能仅更改您自己的程序。考虑到这确实是您的显示器的问题,没有理由不通过更改系统颜色来解决它。
使用控制面板 + 显示屏。在 Win7 上,单击个性化、窗口颜色、高级外观设置。在对话框中选择“禁用项目”。
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.
我不知道这是否有帮助,但这就是我在 C# 中必须做的
I dont know if this would help but this is what I had to do in C#