【问题标题】:VB.net listview checkbox get selected itemVB.net listview 复选框获取所选项目
【发布时间】:2015-05-28 12:04:34
【问题描述】:

我对 ListView 有疑问。单击时如何将 listView 设置为选中?

我的代码:

For Each item As ListViewItem In Me.listAwal.Items 
    item.Selected = True
Next

我使用这个,但如果我选择一个项目,列表视图上的项目都会被选中。

【问题讨论】:

  • Selecteditems 和 CheckedItems 是两个不同的东西

标签: vb.net


【解决方案1】:

听起来您想要获取选中的属性,而是设置选定的属性。试试这个:

For Each item As ListViewItem In Me.listAwal.Items 
    If item.Checked Then
        'Do something with this item
    End If
Next

【讨论】:

  • 正如 Plutonix 所说,checked 和 selected 不是一回事。一个项目可以被选中但不能被选中,反之亦然。也许由于语言障碍,我们误解了您的问题?你能试着澄清你想要做什么吗?
  • For Each item As ListViewItem In Me.listAwal.Items If item.Checked = True Then item.Selected = True ElseIf item.Checked = False Then item.Selected = False End If 'PR Next
  • 现在,我有一个问题,如果我取消选中该项目,listview 上的复选框取消选中所有
  • 您发布的代码不应该发生这种情况。它改变了吗?你在用什么事件处理程序写这个?
  • listview_ item 已检查
猜你喜欢
  • 2023-04-08
  • 2011-05-29
  • 1970-01-01
  • 2011-07-02
  • 2012-08-09
  • 2011-02-10
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多