ListViewCtrl - Which SubItem was selected?

C

cy.johnson

On my access form, I have a ListViewCtrl.
Everything works including figuring out which row the user selected
on.

I can't figure out which column (i.e. subitem) they selected though.
How do I do this?

Details:
ActiveXControl
OLE Class: ListViewCtrl
Class: MSComctlLib.ListViewCtrl.2

Private Sub ActiveXCtl_MyName_Click()
Dim intLoop As Integer

For intLoop = 0 To (Me.ActiveXCtl_MyName.ListItems.count - 1)

If Me.ActiveXCtl_MyNam.ListItems(intLoop + 1).Selected Then
' This is the row that was selected, but how do I figure
out the subitem (or column)

endif

Next intLoop

End Sub
 
D

Douglas J. Steele

Take a look at what Randy Birch has at
http://vbnet.mvps.org/code/comctl/lvhittest.htm

Obligatory warning: Randy's site is aimed at VB programmers. There are some
significant differences between the controls available for forms in VB and
in Access, so that some of his samples won't port directly to Access. This
particular sample, though, shouldn't have any problems.
 
C

Cy

Take a look at what Randy Birch has athttp://vbnet.mvps.org/code/comctl/lvhittest.htm

Obligatory warning: Randy's site is aimed at VB programmers. There are some
significant differences between the controls available for forms in VB and
in Access, so that some of his samples won't port directly to Access. This
particular sample, though, shouldn't have any problems.

Doug,
Thanks for you reply. I finally got it working, with a few
modifications. I am listing them here for other people.
I had the hardest time getting the proper location of the click to
work, but you need to replace
Screen.TwipsPerPixelX and Screen.TwipsPerPixelY with the functions
below.
Thanks again!
--Cy

'http://support.microsoft.com/kb/94927

'--------------------------------------------------
Function TwipsPerPixelX() As Single
'--------------------------------------------------
'Returns the width of a pixel, in twips.
'--------------------------------------------------
Dim lngDC As Long
lngDC = GetDC(HWND_DESKTOP)
TwipsPerPixelX = 1440& / GetDeviceCaps(lngDC, LOGPIXELSX)
ReleaseDC HWND_DESKTOP, lngDC
End Function

'--------------------------------------------------
Function TwipsPerPixelY() As Single
'--------------------------------------------------
'Returns the height of a pixel, in twips.
'--------------------------------------------------
Dim lngDC As Long
lngDC = GetDC(HWND_DESKTOP)
TwipsPerPixelY = 1440& / GetDeviceCaps(lngDC, LOGPIXELSY)
ReleaseDC HWND_DESKTOP, lngDC
End Function
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top