Public Function ListView_SetItemState(hwndLV As Long, i As Long, state As LVITEM_state, mask As LVITEM_state) As Boolean
Dim lvi As LVITEM
lvi.state = LVIS_SELECTED
lvi.stateMask = mask
ListView_SetItemState = SendMessage(hwndLV, LVM_SETITEMSTATE, ByVal 3, lvi)
End Function
Private Sub Check2_Click()
Dim rStyle As Long
Dim r As Long
'get the current ListView style
rStyle = SendMessageLong(ListView1.hwnd, LVM_GETEXTENDEDLISTVIEWSTYLE, 0&, 0&)
If Check2.Value = 0 Then 'remove the extended style bit
rStyle = rStyle Xor LVS_EX_FULLROWSELECT
ElseIf Check2.Value = 1 Then
'set the extended style bit
rStyle = rStyle Or LVS_EX_FULLROWSELECT
End If
'set the new ListView style
r = SendMessageLong(ListView1.hwnd, LVM_SETEXTENDEDLISTVIEWSTYLE, 0&, rStyle)
End Sub