I have a listview box with Multiselect turned on. When I select only the last entry in the listview and remove it from the listview box I get an error:
An unhandled exception of type 'System.ArgumentOutOfRangeException' occurred in system.windows.forms.dll
Additional information: Specified argument was out of the range of valid values.
Private Sub MenuItem1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles MenuItem1.Click
Dim Fi As File
Dim str as String
If ListView1.SelectedItems.Count > 0 Then
Dim i As Integer
For i = 0 To ListView1.SelectedItems.Count - 1
str = ListView1.SelectedItems(i).Text
Fi.Delete(str)
ListView1.Items.Remove(ListView1.SelectedItems(i))
Next
' Deletedfiles = False
' LoadLocalfiles("c:\temp")
Else
MsgBox("Nothing selected")
End If
End Sub
An unhandled exception of type 'System.ArgumentOutOfRangeException' occurred in system.windows.forms.dll
Additional information: Specified argument was out of the range of valid values.
Private Sub MenuItem1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles MenuItem1.Click
Dim Fi As File
Dim str as String
If ListView1.SelectedItems.Count > 0 Then
Dim i As Integer
For i = 0 To ListView1.SelectedItems.Count - 1
str = ListView1.SelectedItems(i).Text
Fi.Delete(str)
ListView1.Items.Remove(ListView1.SelectedItems(i))
Next
' Deletedfiles = False
' LoadLocalfiles("c:\temp")
Else
MsgBox("Nothing selected")
End If
End Sub