Removing the last listview item

vis781

Well-known member
Joined
Aug 30, 2005
Messages
2,016
Location
Cambridge, UK
Programming Experience
5-10
I have run into a problem that has totally confused me....

All i'm trying to do is give the user the option to remove items from a listview using a contextmenu, it works fine up until the last item then vs.net throws an argument out of range exception. Can anyone explain this?
 
Resolved it

Not to worry i sorted it. Funny thing though. I had three listviews and i decided to have one mousedown event handle the showing of the contextmenu. So i added all the handles clauses and used ctype(sender,listview) to get the listview that raised the event. Then on the menitem click event i deleted some rows in a datatable and tried to remove the appropriate listview item. But until i added Application.DoEvents at the bottom of the mousedown sub it gave me an exception when i tried to remove the last item in the listview. Seems a bit strange to me but it works so what the hey....

Thanks for the reply Kulrom:)
 
Back
Top