Remove a line from a ListView

  • Thread starter Thread starter kanenas
  • Start date Start date
K

kanenas

Guest
Hi!

I have a listview and I want to make a button to remove any unwanted
entries. I tried

If Not lst1.SelectedItems Is Nothing Then
lst1.Items.Remove(lst1.SelectedItems(0))
End If

But I got an error in the second line
Any ideas?
 
Of course you cannot remove a selected item if there aren't any. Try wrapping that statement in a Try...Catch block.
 
I would appreciate it if you were more specific because I'm new and quite confused. I don't know how this Try...Catch works!
 
Thanx for the help! It worked but
Msgbox(ex1.Description)
was unnecessary. At least it worked without it!
 
Back
Top