ListView out of range exception

P

Pengyu

Whenever I call listView.RemoveAt(listView.Count-1),
which remove the last item, I get an out of range
exception. How to solve this problem?

Thanks a lot,

Pengyu.
 
C

Chad Z. Hower aka Kudzu

Pengyu said:
Whenever I call listView.RemoveAt(listView.Count-1),
which remove the last item, I get an out of range
exception. How to solve this problem?

Where are you calling this from? Are you calling this from a click or other
event of the listview? Listview tries to access itself after the event, so if
you remove the last item it cannot access it and triggers this error.

Its a real PITA with the list view.


--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programming is an art form that fights back"

Empower ASP.NET with IntraWeb
http://www.atozed.com/IntraWeb/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top