Setting Checked property does not change check state

Summary

Id: 4089.15
Type: Bug Bug
Current Status: Resolution Identified

Detail

6 Jul 2003 Open Brent Leimenstoll

…when I was attempting to set the checked property of a listitem, the control simply toggled the value. Again, I hacked the code and discovered that it was never recognizing the bState variable. I adjusted the code, as shown below, and it works like a charm.

Friend Property Let fItemChecked(ByVal lIndex As Long, ByVal bState As Boolean)
Dim lR As Long
Dim tLV As LVITEM
   
tLV.iItem = lIndex - 1
tLV.mask = LVIF_STATE
tLV.stateMask = LVIS_STATEIMAGEMASK
Call SendMessage(m_hWnd, LVM_GETITEM, 0&, tLV)
If bState Then
  ' uncheck
  tLV.State = &H2000
Else
  ' check
  tLV.State = &H1000
End If
lR = SendMessage(m_hWnd, LVM_SETITEMSTATE, lIndex - 1, tLV)
   
End Property
14 Nov 2003 Resolution Identified Steve McMahon

Doh! Fixed as suggested.