【问题标题】:How to get the index number of the selected listview item如何获取所选列表视图项的索引号
【发布时间】:2011-06-18 08:05:32
【问题描述】:

我已经在我的列表视图中设置了这些选项

  • multiSelect = 假
  • 查看=详细信息
  • FullRow 选择 = true
  • HideSelected = 假。

我有一列有 10 个项目。我想在 vb.net

中获取选定的行索引

【问题讨论】:

    标签: vb.net winforms listview listviewitem


    【解决方案1】:
    Dim index As Integer = ListView1.SelectedIndices(0)
    

    记住 VB.NET 中的索引是从 0 开始的。

    【讨论】:

      【解决方案2】:

      试试这个:

      Dim x as Integer
      x = ListView1.FocusedItem.Index
      

      获取值:

      Dim txtValue as String
      txtValue = ListView1.FocusedItem.SubItems(0).text
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2017-03-19
        • 1970-01-01
        • 2013-05-17
        • 1970-01-01
        • 2022-11-23
        • 2014-08-14
        • 1970-01-01
        相关资源
        最近更新 更多