I'm Horrible at ListViews

Started by craigsca, July 02, 2009, 12:13:58 AM

Previous topic - Next topic

craigsca

Just trying to get the item selected.  The first time I make my selection in the listbox, the msgbox pops up with the correct entry.  The second time I select from the listbox, I get 3 msgboxes.  The first and second say my selection was the first selection - finally, the third msgbox gives the correct answer.  When I click my listview, why am I getting multiple answers (selections)?


FUNCTION FRMROSTER_LISTVIEW1_LVN_ITEMCHANGED ( _
                                             ControlIndex  AS LONG,            _  ' index in Control Array
                                             hWndForm      AS DWORD,           _  ' handle of Form
                                             hWndControl   AS DWORD,           _  ' handle of Control
                                             BYVAL lpNMV   AS NM_LISTVIEW PTR  _  ' pointer to NM_LISTVIEW
                                             ) AS LONG

MSGBOX "you selected " + STR$(@lpNMV.iITEM+1)

TechSupport

Hi,

I think that the following is what you need (i.e. specifically check for the state change in the message. I think that I got this from a search in POFFS or the PB forums.


Function FORM1_LISTVIEW1_LVN_ITEMCHANGED ( _
                                         ControlIndex  As Long,            _  ' index in Control Array
                                         hWndForm      As Dword,           _  ' handle of Form
                                         hWndControl   As Dword,           _  ' handle of Control
                                         ByVal lpNMV   As NM_LISTVIEW Ptr  _  ' pointer to NM_LISTVIEW
                                         ) As Long

   If IsTrue (@lpNMV.uNewState And %LVIS_SELECTED) Then
      MsgBox "you selected " + Str$(@lpNMV.iITEM) + Str$(@lpNMV.iSubITEM)
   End If
   
End Function


craigsca