Vb.net 选中列表视图中的所有复选框

Vb.net 选中列表视图中的所有复选框,vb.net,Vb.net,我想有一个按钮,将选中我的listview中的所有复选框 Dim I as Integer If listViewAccounts.CheckedItems.Count > 0 then (>>My Problem here<<) End if 下一步要做什么?或者直接使用Linq for i = 0 to listViewAccounts.Items.Count -1 listVie

我想有一个按钮,将选中我的listview中的所有复选框

        Dim I as Integer
        If listViewAccounts.CheckedItems.Count > 0 then

           (>>My Problem here<<)

        End if
下一步要做什么?

或者直接使用Linq

for i = 0 to listViewAccounts.Items.Count -1
   listViewAccounts.Items(i).Checked = true
next
listView1.Items.OfType(Of ListViewItem).All(Function(c)
                                              c.Checked = True
                                              Return True
                                            End Function)
或者直接使用Linq

listView1.Items.OfType(Of ListViewItem).All(Function(c)
                                              c.Checked = True
                                              Return True
                                            End Function)

把Items[i]改为Items i,我会投你一票;似乎不起作用。我改了。但是后来。什么也没发生,没有纠正!利奥,你确定那不行吗?尝试将上面的代码放在按钮中,然后单击按钮。应检查所有项目。是否确实在listview上启用了复选框。listview是否处于详细信息模式?@JonBarker Top+1.它现在工作了,问题是,我在上面的代码之间插入了你的代码;似乎不起作用。我改了。但是后来。什么也没发生,没有纠正!利奥,你确定那不行吗?尝试将上面的代码放在按钮中,然后单击按钮。应检查所有项目。是否确实在listview上启用了复选框。listview是否处于详细信息模式?@JonBarker Top+1.它现在工作了,问题是,我在上面的代码之间插入了你的代码。