dl0haus

I need to get the index of a selected item in at ListView. This is for a single-select ListView. I understand how to get the collection of selected items but since that doesn't be 0 good, I was hoping there was a way to get the index into the ListView so I could directly reference row items... How is this done

D



Re: Windows Forms General Getting selected index from ListView

TilakGopi

Hi,

One way is

ListView.SelectedIndexCollection sc = lvEmployees.SelectedIndices;

Anyway the list view is made single-selected, this collection will have only one element.

Hope this works for u.

Thanx,

Ch.T.Gopi Kumar.






Re: Windows Forms General Getting selected index from ListView

Figo Fei - MSFT

Hi,

You can simply use ListView.SelectItems[0]

Thanks






Re: Windows Forms General Getting selected index from ListView

TilakGopi

Hi dl0haus and Figo Fei ,

Never mind ,

what's the wrong with my answer,i'm not getting

Could u please let me know that

Thanx in advance.

BestRegards,

Ch.T.Gopi Kumar.






Re: Windows Forms General Getting selected index from ListView

Figo Fei - MSFT

You are right, listView1.SelectedIndices get the collection of indices while listView1.SelectedItems get the collection information of items.

That's the difference.

Thanks






Re: Windows Forms General Getting selected index from ListView

TilakGopi

Hi Figo,

Thanks for clearing my nuts , my intention is know whether i can use that way or not , not to make my post as answered.Hope u got me.

Best Regards,

Ch.T.Gopi Kumar.