SelectedIndices in ListView

  • Thread starter Thread starter Alberto
  • Start date Start date
A

Alberto

In the event SelectedIndexChanged of a listView I wrote this code:
this.Text = lst.SelectedIndices[0].ToString();

The ListView has the MultiSelect property set to false.
The first time the event is called it works fine but in the second call, it
breaks.

does anybody why?
Thank you very much
 
Alberto,

I don't know if this is the best method, however it goes.

(Assuming you use it in the index changed event, it is fired when you
deselect you know)

if (lst.SelectedIndices.Count != 0)
{
this.Text = lst.SelectedItems[0].ToString();
}

I hope this helps

Merry Christmas

Cor
 
Back
Top