本文介绍了不会从listbox1项中删除的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我从list1移到list2时,它将正常工作.
但是,与此同时,它不会从list1中删除.
我的代码有什么问题.
请参见下面的代码.
-----------------
Hi,
When i move from list1 to list2, it will working fine.
but, meantime it will not be deleting from list1.
what is the problem in my code.
see code below.
-----------------
If lstTot.SelectedIndex > -1 Then
Dim _value As String = lstTot.SelectedItem.Value
Dim _text As String = lstTot.SelectedItem.Text
Dim item As New ListItem()
item.Text = _text
item.Value = _value
For Each li As ListItem In lstTot.Items
If li.Selected = True Then
lstEx.Items.Add(li.Text)
lstTot.Items.Remove(li.Text)
End If
Next
End If
推荐答案
For Each obj As Object In lstTot.SelectedItems
lstEx.Items.Add(obj)
Next
While lstTot.SelectedIndices.Count > 0
lstTot.Items.RemoveAt(lstTot.SelectedIndices.Item(0))
End While
这篇关于不会从listbox1项中删除的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!