ZoolWay
ZoolWay

Reputation: 5505

.NET ListView Selected issues

I am trying to select an item in a single select ListView. I know you should do it by setting the Selected property to the item to true.

Everything works fine so far but when I set Selected to true, the SelectedItems collection is not update and the SelectedIndexChanged event is not fired. When manipulating the SelectedIndices list I get the same problem: No event, no update of the collection.

Any ideas?


Just to make clear, the event is fired but it happens an undefined ammount of time after Selected is changed. Same is for ItemSelectedChanged event. I am working on a WinForms app.

Upvotes: 0

Views: 354

Answers (1)

phhkafot
phhkafot

Reputation: 183

(assuming you are talking about a WinForms application)

I may be wrong, but from my experience the ListView's SelectedIndexChanged event is not as reliable as you might think it would be. I think you'd better use the ItemSelectionChanged event.

Interesting link: http://jerryandcheryl.net/jspot/2009/01/listview-selectedindexchanged-vs-itemselectionchanged/

Upvotes: 1

Related Questions