VB.NET中要删除列表框中的多个选项,请问代码如何编写。我下面的代码错在哪里请指导,谢谢
DimiAsIntegerIfListBox1.SelectedIndex>0Then'ListBox1.Items.RemoveAt(ListBox1.Selected...
Dim i As Integer
If ListBox1.SelectedIndex > 0 Then
' ListBox1.Items.RemoveAt(ListBox1.SelectedIndex)
For i = ListBox1.SelectedIndex - 1 To 0 Step -1
If ListBox1.SelectedIndex(i) Then
ListBox1.Items.RemoveAt(i)
End If
Next i
End If 展开
If ListBox1.SelectedIndex > 0 Then
' ListBox1.Items.RemoveAt(ListBox1.SelectedIndex)
For i = ListBox1.SelectedIndex - 1 To 0 Step -1
If ListBox1.SelectedIndex(i) Then
ListBox1.Items.RemoveAt(i)
End If
Next i
End If 展开
1个回答
展开全部
For i = List1.ListCount - 1 To 0 Step -1
If List1.Selected(i) Then
List1.RemoveItem (i)
End If
Next i
追问
是要在VB.NET中,上面的代码是在VB中吧
追答
For Each Item As String In ListBox1.SelectedItems
dict.Add(Item, Item)
Next
For Each i As String In dict.Keys
ListBox1.Items.Remove(i)
Next
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询