Re: ListView.SelectedIndexChanged problem by Alex
Alex
Tue Sep 09 17:33:23 CDT 2003
On [GMT+0100=CET],
Simon Jackson <simon.jackson@alexismedical.co.uk> thought hard and spewed:
> By navigating do you mean using the ListView scroll bar
> (or arrow keys) to scroll the list? If so then the
> behaviour you describe is correct. Scrolling the ListView
> will not affect its SelectedIndices collection.
>
Yes, either by arrow keys, or mouse click, it doesn't matter, the same bug.
> Also be aware that when you change a ListView selection
> it is possible to receive 2 SelectedIndexChanged events,
> 1 having the SelectedIndices collection set to 0
> elements. This is because the when a user initiates a
> selection change that effectively results in all items
> being deselected and then 1 (or more) items being
> reselected the control actually tells you about both
> events (even though it appears as one operation to the
> user).
>
Initially as I navigate I get the proper SelectedIndices, but as soon as I
put focus to another control and then go back to the ListView to navigate,
the SelectedIndices have 0 elements.
> These aren't so much bugs as nuances with the way the
> control is implemented. When you code against the
> SelectedIndices collection test
> ListView.SelectedIndicies.Count to make sure there is at
> least 1 element.
>
I'm sorry you think it's a feature, but I think it's a faulty
implementation. Also I never get 2 events in a row.