VB Listview 前面有Checkbox 怎样判断"没有选中任何项",即前面勾勾都没有被勾上,一项也没有!
答案:3 悬赏:80 手机版
解决时间 2021-03-09 02:03
- 提问者网友:蔚蓝的太阳
- 2021-03-08 18:20
VB Listview 前面有Checkbox 怎样判断"没有选中任何项",即前面勾勾都没有被勾上,一项也没有!
最佳答案
- 五星知识达人网友:你哪知我潦倒为你
- 2021-03-08 18:26
可参考下面例子,有选中项时分别列出选中项名称,无选中项时,显示“无选中项”
Private Sub ListView1_ItemChecked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ItemCheckedEventArgs) Handles ListView1.ItemChecked
Dim txt As String = Nothing
For Each listitem As ListViewItem In ListView1.Items
If listitem.Checked Then
txt += listitem.Text + ","
End If
Next
If txt = Nothing Then
TextBox1.Text = "没有选中项"
Else
TextBox1.Text = txt
End If
End Sub
Private Sub ListView1_ItemChecked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ItemCheckedEventArgs) Handles ListView1.ItemChecked
Dim txt As String = Nothing
For Each listitem As ListViewItem In ListView1.Items
If listitem.Checked Then
txt += listitem.Text + ","
End If
Next
If txt = Nothing Then
TextBox1.Text = "没有选中项"
Else
TextBox1.Text = txt
End If
End Sub
全部回答
- 1楼网友:慢性怪人
- 2021-03-08 20:48
ListViewMain.SelectedIndex
当它为-1时,表示没有选中,大于-1时表示已经选择
- 2楼网友:愁杀梦里人
- 2021-03-08 19:08
list1.clear: list2.clear
for i = 1 to listview1.listitems.count
if listview1.listitems.item(i).checked = true then
list1.additem listview1.listitems.item(i).subitems(1)
else
list2.additem listview1.listitems.item(i).subitems(1)
end if
next
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯