Based a checkbox on listview i need to filla array or collection based a click on...
Example:
click on checkbox on row 4, is true in this case, fill array or collection with the related value in column 1
click on checkbox on row 14, is true in this case, append the related value of array or collection, with the related value in column 1
ecc...
if i reclick on, checkbox,is false in this case, on row 4, delete the related value, in the array or collection
ecc...
how to?
Hope understand me.
Fill array or collection with checkbox click in listview
-
- PlatinumLounger
- Posts: 4357
- Joined: 26 Apr 2010, 17:36
-
- Administrator
- Posts: 78512
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Fill array or collection with checkbox click in listview
Declare a variable Dict of type Object:
In the Load event of the form, add the line
Create an event procedure for the ItemCheck event of the ListView control:
Code: Select all
Dim Dict As Object
Code: Select all
Set Dict = CreateObject("Scripting.Dictionary")
Code: Select all
Private Sub ListView1_ItemCheck(ByVal Item As MSComctlLib.ListItem)
If Item.Checked Then
Dict.Add Item:=Item.Text, Key:=Item.Text
Else
Dict.Remove Key:=Item.Text
End If
End Sub
Best wishes,
Hans
Hans
-
- PlatinumLounger
- Posts: 4357
- Joined: 26 Apr 2010, 17:36
Re: Fill array or collection with checkbox click in listview
FEW LINES, BIG CODE!HansV wrote: ↑16 Mar 2023, 16:27Declare a variable Dict of type Object:
In the Load event of the form, add the lineCode: Select all
Dim Dict As Object
Create an event procedure for the ItemCheck event of the ListView control:Code: Select all
Set Dict = CreateObject("Scripting.Dictionary")
Code: Select all
Private Sub ListView1_ItemCheck(ByVal Item As MSComctlLib.ListItem) If Item.Checked Then Dict.Add Item:=Item.Text, Key:=Item.Text Else Dict.Remove Key:=Item.Text End If End Sub
tks bro