i want to remove selected items from a list box
this is the code i'v used
Expand|Select|Wrap|Line Numbers
- Private Sub btnRemove_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRemove.Click, lstSelNum.DoubleClick
- For Each i As Integer In lstSelNum.SelectedIndices
- txtSearch.Text += i & " - "
- lstSelNum.Items.RemoveAt(i)
- Next
- End Sub
Eg.
if i select 4 then it'l remove only 3
but when i used the following code
Expand|Select|Wrap|Line Numbers
- Private Sub btnRemove_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRemove.Click, lstSelNum.DoubleClick
- 'lstSelNum.Items.Remove(lstSelNum.SelectedItem)
- For Each i As Integer In lstSelNum.SelectedIndices
- txtSearch.Text += i & " - "
- 'lstSelNum.Items.RemoveAt(i) ---- commented
- Next
- End Sub
please help me to fix it.
Thanks
Chathura