Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Listview select error

Status
Not open for further replies.

Nickaroo

MIS
Mar 24, 2003
21
US
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top