Click here to Skip to main content
16,018,949 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to get the index of the selected row in the listview.
Posted
Updated 31-May-12 23:50pm
v2

Try this:

VB
Dim x as Integer
x = ListView1.FocusedItem.Index


Or else

VB
Dim index As Integer = ListView1.SelectedIndices(0)


Or else

VB
int index = 0;
if (this.myListView.SelectedItem.Count > 0)
index = this.myListView.SelectedIndices[0]


Or else

Use ListView.SelectedIndex Property[^]
 
Share this answer
 
v2
Comments
PunithaSabareeswari 1-Jun-12 6:16am    
Thank you
Prasad_Kulkarni 1-Jun-12 6:57am    
You're welcome!
If it's really helpful for you then formally 'Accept solution'
Prasad_Kulkarni 1-Jun-12 7:32am    
Glad it helps!
C#
Textbox1.Text =  listview1.Items.Item(listview1.FocusedItem.Index).SubItems.Item(column_number).Text
 
Share this answer
 
v2
Comments
PunithaSabareeswari 1-Jun-12 6:14am    
Hi... I try this.. But i had error "InvalidArgument=Value of '0' is not valid for 'index'. Parameter name: index" when i choose item from listview.
PunithaSabareeswari 1-Jun-12 6:19am    
I got it.... Thank you...
ujju.1 1-Jun-12 7:08am    
good :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900