列表视图 C# 保持选中状态
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/243914/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
List View C# stay selected
提问by Maria Jo?o
I have a list view that after a double click, a record opens a new form to show the details, but the record in the list view lost the "selection".... How do I know which record was clicked ???
我有一个列表视图,双击后,记录打开一个新表单以显示详细信息,但列表视图中的记录丢失了“选择”....我怎么知道点击了哪条记录???
Thanks
谢谢
Maria Jo?o
玛丽亚·乔?
回答by Stu Mackellar
Try setting the HideSelection property on the list view to false. It's enabled by default.
尝试将列表视图上的 HideSelection 属性设置为 false。它默认启用。
回答by BenR
The listview control has a HideSelectionproperty that defaults to True. Set this to False and the current row will remain highlighted even if the control loses focus.
列表视图控件具有默认为 True的HideSelection属性。将此设置为 False,即使控件失去焦点,当前行也将保持突出显示。
回答by Mark Lakata
Note that the selection will turn "gray" when focus is lost, and "blue" when focused. Keeping it blue when the focus is lost is more difficult ... you'll have to override the ListView::DrawItem
请注意,当失去焦点时,选择将变为“灰色”,而在聚焦时将变为“蓝色”。失去焦点时保持蓝色更困难......你必须覆盖 ListView::DrawItem