6
Answers

ListView_SelectedIndexChanged event

Ask a question
Administrator

Administrator

21y
2.8k
1
I have a listview which can contain a large number of items (files, sizes are included) and in the status bar of the application I show how many items are selected and the total number of bytes of all the selected files. I have a handle set up for ListView_SelectedIndexChanged to caluculate this information and place it on the statusbar. At first my "Select All" was pretty slow as it looped through the items in the ListView and set them to selected one at a time which called my selected index changed event (once for each time an item was selected) and calculated the total. I solved this problem by having my select all function -= the event handler before it started and then re-adding it and then manaually calling it when it was done selecting everything. That worked great, but now my problem is whenever I have everything selected and then select one item the framework calls the ListView_SelectedIndexChanged once for every item it deselects. And this is slowwwww. Does anyone have an idea about how I fix this up?

Answers (6)