Article ID: 145728
Article Last Modified on 6/29/2004
ListView1.Icons = ImageList1
ListView1.SmallIcons = ImageList2
'store the item selected in the ItemClick event
'for use in the DblClick event
Private ItemClicked As ListItem
Private Sub Form_Load()
Dim itmX As ListItem
Dim i As Integer
'loop and add 10 items to the ListView control
'this code should be replaced by your add item code
For i = 1 To 10
Set itmX = ListView1.ListItems.Add()
'set icon to unchecked
itmX.SmallIcon = 1
itmX.Text = "ListItem " & i
Next i
'other views will work, but will allow additional
'behavior over a standard listbox
ListView1.View = lvwList
'display full label
ListView1.LabelWrap = False
End Sub
Private Sub ListView1_DblClick()
'toggle icon between checked and unchecked
'use the private ItemClicked variable set in the
'ListView1_ItemClick event
With ItemClicked
If .SmallIcon = 1 Then
.SmallIcon = 2
Else
.SmallIcon = 1
End If
End With
End Sub
Private Sub ListView1_ItemClick(ByVal Item As ListItem)
'since there is no ItemDblClick event, save the item
'clicked on for use in the ListView's DblClick Event
Set ItemClicked = Item
End Sub
Additional query words: kbVBp400 kbVBp500 kbVBp600 kbVBp kbdsd kbDSupport kbControl
Keywords: kbhowto KB145728