1. ListView has Multiselect = true
2. I handle the above-mentioned event.
3. SelectedIndices collection has 0 elements when navigating by mouse-click
or up/down arrow

I need to have Multiselect on to support deleting multiple items at time.
But I tried with multiselect=false, and I still get SelectedIndices
collection with 0 elements. All this leads me to believe that .NET 1.1
ListView has a bug.

ListView.SelectedIndexChanged problem by Simon

Simon
Tue Sep 09 16:53:09 CDT 2003

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.

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).

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.

HTH,

Simon.
>-----Original Message-----
>1. ListView has Multiselect = true
>2. I handle the above-mentioned event.
>3. SelectedIndices collection has 0 elements when
navigating by mouse-click
>or up/down arrow
>
>I need to have Multiselect on to support deleting
multiple items at time.
>But I tried with multiselect=false, and I still get
SelectedIndices
>collection with 0 elements. All this leads me to believe
that .NET 1.1
>ListView has a bug.
>
>
>.
>

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.