SpongeBob SquarePants
SpongeBob SquarePants

Reputation: 1055

How to get the index number of the selected listview item

I have set these options on my listview

I have one column which has 10 items. I want to get the selected row index in vb.net

Upvotes: 2

Views: 65524

Answers (2)

Benjie
Benjie

Reputation: 41

Try this one:

Dim x as Integer
x = ListView1.FocusedItem.Index

To get the values:

Dim txtValue as String
txtValue = ListView1.FocusedItem.SubItems(0).text

Upvotes: 4

John Alexiou
John Alexiou

Reputation: 29244

Dim index As Integer = ListView1.SelectedIndices(0)

remember indeces in VB.NET are 0-based.

Upvotes: 2

Related Questions