Anti-Rich
Well-known member
Hi all,
is there an easy way to access a single selected item on a listview? i find that when i try to reference it using various methods, its always unreliable or crashing on me. for instance if i try
sometimes it will work, but other times its saying that 0 is not a valid index. if i dont supply anything it says that selecteditems doesnt accept that number of arguments. wouldnt 0 be a valid index, as 0 would represent teh first item in the selecteditems collection?
another method i thought of was just to use a function to search for the selected item,
ie.
now for an unknown reason sometimes it just returned the wrong index.
this is pretty frustrating, and if anyone could shed some light on the situation id be greatly appreciative.
regards
adam
is there an easy way to access a single selected item on a listview? i find that when i try to reference it using various methods, its always unreliable or crashing on me. for instance if i try
VB.NET:
TheId = lstEquipment.SelectedItems(0).Text
sometimes it will work, but other times its saying that 0 is not a valid index. if i dont supply anything it says that selecteditems doesnt accept that number of arguments. wouldnt 0 be a valid index, as 0 would represent teh first item in the selecteditems collection?
another method i thought of was just to use a function to search for the selected item,
ie.
VB.NET:
dim c as integer=0
For each i as listviewitem in lvEquipment.items
if not i.selected
c+=1
end if
next
return c
now for an unknown reason sometimes it just returned the wrong index.
this is pretty frustrating, and if anyone could shed some light on the situation id be greatly appreciative.
regards
adam