Returns or sets a value that determines if checkboxes appear, the number of boxes checked, and a collection of selected items.
ListView.CheckBoxes [ = Boolean ]
ListView.CheckedCount
ListView.CheckedItems
ListItem.Checked
When CheckBoxes = True, checkboxes will appear. By default, they don't appear.
The CheckedCount returns the number of checkboxes that are checked.
CheckedItems returns a reference to a ListItems collection containing all checked items.
ListItem.Checked returns or sets a Boolean that determines the checked state of the list item's check button.
Local ch As ColumnHeader, li As ListItem
Ocx ListView lv = "", 10, 10, 300, 200
.View = 3 : .FullRowSelect = True
Set ch = lv.ColumnHeaders.Add( ,"1", "Checkbox") : ch.Width = 900
lv.ColumnHeaders.Add , "2", "Description" : lv.ColumnHeaders(2).Width = 2500
lv.CheckBoxes = True
lv.Add , , "" : lv.ListItem(1).AllText = ";Checkbox 1" : lv.ListItem(1).Checked = True
lv.Add , , "" : lv.ListItem(2).AllText = ";Checkbox 2"
lv.Add , , "" : lv.ListItem(3).AllText = ";Checkbox 3"
Do : Sleep : Until Me Is Nothing
Sub lv_ItemClick(Item As ListItem)
lv_Report
EndSub
Sub lv_MouseUp(Button&, Shift&, x!, y!)
lv_Report
EndSub
Sub lv_Report
Local li As ListItem, a$
If lv.CheckedItems.Count = 0 // lv.CheckedCount can be used instead
a$ = "No CheckBoxes are checked."
Else
a$ = "The following items are checked:"#13#10#13#10
For Each li In lv.CheckedItems
a$ = a$ & "Checkbox " & li.Index & #13#10
Next
EndIf
Message a$
EndSub
CheckedCount is equivalent to CheckedItems.Count.
{Created by Sjouke Hamstra; Last updated: 25/09/2014 by James Gaite}