Article ID: 181440
Article Last Modified on 6/29/2004
Private Declare Function SendMessage Lib "user32" Alias _
"SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal _
wParam As Long, lParam As Any) As Long
Const LVS_EX_FULLROWSELECT = &H20
Const LVM_FIRST = &H1000
Const LVM_GETEXTENDEDLISTVIEWSTYLE = LVM_FIRST + &H37
Const LVM_SETEXTENDEDLISTVIEWSTYLE = LVM_FIRST + &H36
Private Sub Command1_Click()
Dim lStyle As Long
lStyle = SendMessage(ListView1.hwnd, _
LVM_GETEXTENDEDLISTVIEWSTYLE, 0, 0)
lStyle = lStyle Or LVS_EX_FULLROWSELECT
Call SendMessage(ListView1.hwnd, LVM_SETEXTENDEDLISTVIEWSTYLE, _
0, ByVal lStyle)
End Sub
Private Sub Form_Load()
'Add two Column Headers to the ListView control
Set clmAdd = ListView1.ColumnHeaders.Add(Text:="Name")
Set clmAdd = ListView1.ColumnHeaders.Add(Text:="Date")
'Set the view property of the Listview control to Report view
ListView1.View = lvwReport
'Add data to the ListView control
Set itmAdd = ListView1.ListItems.Add(Text:="Joe")
itmAdd.SubItems(1) = "05/07/97"
Set itmAdd = ListView1.ListItems.Add(Text:="Sally")
itmAdd.SubItems(1) = "04/08/97"
Set itmAdd = ListView1.ListItems.Add(Text:="Bill")
itmAdd.SubItems(1) = "05/29/97"
Set itmAdd = ListView1.ListItems.Add(Text:="Fred")
itmAdd.SubItems(1) = "05/17/97"
Set itmAdd = ListView1.ListItems.Add(Text:="Anne")
itmAdd.SubItems(1) = "04/01/97"
End Sub
Keywords: kbhowto KB181440