Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Listview finding selected row number

Status
Not open for further replies.

SteveMac32

Programmer
Jan 25, 2002
74
0
0
GB
Hi all
This is/should be a simple one but for some reason I just can’t get it, I think my brain has gone for a long walk.

I load the listview from a recordset and when the user clicks on a row I want to be able to look in a particular element and if that element holds a true value we can then proceed, easy enough I thought:

If vwData.ListItems(RowNum).SubItems(17) = True Then

Which will bring me the element 17 from the specified row, the problem is how do I find out what the row number is?

Thanks all
 
Private Sub ListItems_DblClick()

MyRowNumber = vwData.ListItems.SelectedItem.Index

End Sub

[gray]Experience is something you don't get until just after you need it.[/gray]
 
>when the user clicks on a row

Then your ListView gets an ItemClick event, which passes the clicked Item as a paremeter

1) Item.Index contains the row number

but, perhaps more importantly

2) Item already represents the clicked ListView item, so you just need to check Item.SubItems(17)

 
Thanks Guys

That was the road i was going down but i keep getting these errors:
vwData.ListItems.SelectedItem.Index
‘Method or data member not found’ on SelectedItem


vwData.ListItems.Item.SubItems(17)
‘Argument not optional’ on Item

thought i must have some strange property values but finally
vwData.SelectedItem.Index
Gave me the answer

Thanks for your help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top