vb.net 如何获取所选列表视图项的索引号
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4847044/
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
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 15:15:23 来源:igfitidea点击:
How to get the index number of the selected listview item
提问by SpongeBob SquarePants
I have set these options on my listview
我在我的列表视图上设置了这些选项
- multiSelect = false
- view = details
- FullRow select = true
- HideSelected = False.
- 多选=假
- 查看 = 详细信息
- 全行选择 = 真
- 隐藏选择 = 假。
I have one column which has 10 items. I want to get the selected row index in vb.net
我有一列有 10 个项目。我想在vb.net 中获取选定的行索引
采纳答案by ja72
Dim index As Integer = ListView1.SelectedIndices(0)
remember indeces in VB.NET are 0-based.
记住 VB.NET 中的 indeces 是基于 0 的。
回答by Benjie
Try this one:
试试这个:
Dim x as Integer
x = ListView1.FocusedItem.Index
To get the values:
要获取值:
Dim txtValue as String
txtValue = ListView1.FocusedItem.SubItems(0).text