Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
 
 
 
 
 
 
 
Old Pages
 
Old Index
Site Map
What's New
 
Books
How To
Tips & Tricks
Tutorials
Stories
Performance
Essays
Links
Q & A
New in VB6
Free Stuff
Pictures
 
 
 
TitleMake a checkbox list
Keywordscheck box, CheckBox, list, check list
CategoriesControls
 
Use a ListView control. Use the items' SmallIcon properties to display checked and unchecked icons.
 
Private Enum IconValues
    iconUnchecked = 1
    iconChecked = 2
End Enum

Private Sub Form_Load()
Dim i As Integer

    ' Associate ImageList1 with the ListView's
    ' small icons.
    ListView1.SmallIcons = ImageList1
    ListView1.View = lvwList
    ListView1.LabelWrap = False

    ' Make some list items and set their
    ' SmallIcons to the unchecked icon.
    For i = 1 To 10
        ListView1.ListItems.Add , , "Item " & Format$(i), , _
            iconUnchecked
    Next i
End Sub

' Toggle the item's checked state.
Private Sub ListView1_ItemClick(ByVal Item As ListItem)
    With Item
        If .SmallIcon = 1 Then
            .SmallIcon = 2
        Else
            .SmallIcon = 1
        End If
    End With
End Sub
 
 
Copyright © 1997-2003 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated