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. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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 | |
|
|