A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

ListViewCtrl - Which SubItem was selected?



 
 
Thread Tools Display Modes
  #1  
Old December 15th, 2007, 04:49 PM posted to microsoft.public.access.forms
[email protected]
external usenet poster
 
Posts: 2
Default ListViewCtrl - Which SubItem was selected?

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
  #2  
Old December 15th, 2007, 06:16 PM posted to microsoft.public.access.forms
Douglas J. Steele
external usenet poster
 
Posts: 9,313
Default ListViewCtrl - Which SubItem was selected?

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.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)


wrote in message
...
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



  #3  
Old January 5th, 2008, 11:05 PM posted to microsoft.public.access.forms
Cy
external usenet poster
 
Posts: 1
Default ListViewCtrl - Which SubItem was selected?

On Dec 15 2007, 10:16 am, "Douglas J. Steele"
wrote:
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 Steele, Microsoft Access MVPhttp://I.Am/DougSteele
(no private e-mails, please)

wrote in message

...

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


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
 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 06:49 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.