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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Double Click on Listview

Status
Not open for further replies.

StormbringerX

Programmer
Dec 14, 2000
102
US
I have a form with a listview control. The Control is set to Report View. I have 2 subitems associated with it. The Listview is displaying great. What I need to do now is: on the doubleclick event I simply want to capture the contents of the key to a variable. I just can't quite get my head wrapped around how to accomplish this. Thanks for any help
Dave
 
Try this code.

Dim Item As ListItem

If ListView1.HitTest(xpos, ypos) Is Nothing Then
Exit Sub
Else
Set Item = ListView1.HitTest(xpos, ypos)
End If

After you double click on the item, the variable Item will contain the listitem that you double clicked on. From there you can use Item.Key if you set the Key value when you loaded the ListView control. Snaggs
tribesaddict@swbell.net
 
Thanks Snaggs. I beleive with your help I may have solved the puzzle!
Dave
 
I forgot to mentation in the code I posted above should be placed in the DoubleClick event of the ListView. But I'm sure you knew that, or have figured it out by now. Snaggs
tribesaddict@swbell.net
 
Another way is:

Dim item as ListItem

if Listview1.SelectedItem is nothing then exit sub

Set item = Listview1.SelectedItem
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top