I have a listview (in Details view) that is filled dynamically. I want to grab the text from the the first item in the listview.
This code doesn’t work
lstSalesppl.Items[0].Selected = true;
string teamLeader = lstSalesppl.SelectedItems[0].Text;
I get an error on the second line: Invalid argument=Value of ‘0’ is not valid for ‘index’ however the same code works in another method when the listview item is double clicked
Can anyone tell me what I’m doing wrong?
Thanks
try using
rather than
lstSalesppl.SelectedItemsmay not be bound to theSelectedattributeListView.SelectedItems Property