Guest cgchris99 Posted August 19, 2002 Posted August 19, 2002 I wanted to be able to tell which Item/Image was selected in a ListView. I have the multiselect set to false. I only want them to pick one item at a time. So here is my code test=iew.SelectedIndices(0) This works only the first time they pick one. If they pick a different item in the list, it throws an exception. Any ideas? Second question. Can I keep the selected image from turning blue? Or is there a way to have it display a different image for the selected one? Thanks Quote
*Gurus* divil Posted August 19, 2002 *Gurus* Posted August 19, 2002 I think there is a FocusedItem property to tell which item has the focus. I'm not sure about your second question, is there not a SelectedImage property of the ListItem class? Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
donaldc104 Posted January 17, 2003 Posted January 17, 2003 Protection for lvw.SelectedIndices You need to protect the index selection. Make sure that there is only one item selected before using SelectedIndices. Here's an example: If ListView1.SelectedItems.Count = 1 Then intIndex = Int(ListView1.SelectedIndices(0)) hope this helps. ;) Quote
jasonbstubbs Posted December 5, 2003 Posted December 5, 2003 The last response is correct. If you step through the code, you'll find that the second time you process the event, selecteditems.count will be 0. Quote
Engine252 Posted December 5, 2003 Posted December 5, 2003 and to answer on you second question you can change the image index of the selected index to give it another look :-) Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.