listview listitems

kimt
10-23-2004, 09:39 PM
Have filled a listview with checkboxes with ID, Lastname and firstname. I now want to add the ID to a collection but am having trouble identifying that all are in the collection. Here is what I have:

Dim i As Integer
Dim cCol As New Collection
With listview1
For i = 1 To .ListItems.Count
If .ListItems(i).Checked Then
lngID = .ListItems(i).Checked ' this returns True/False
lngid = .selecteditem 'returns the current item only
cCol.Add lngID
End If
Next i
End With

When one or all checkboxes are checked, I would like to 'collect' them to further manipulate the data.

Any help would be greatly appreciated.

Thanx.

Kim

Dennis DVR
10-24-2004, 05:27 AM
Have filled a listview with checkboxes with ID, Lastname and firstname. I now want to add the ID to a collection but am having trouble identifying that all are in the collection. Here is what I have:

Dim i As Integer
Dim cCol As New Collection
With listview1
For i = 1 To .ListItems.Count
If .ListItems(i).Checked Then
lngID = .ListItems(i).Checked ' this returns True/False
lngid = .selecteditem 'returns the current item only
cCol.Add lngID
End If
Next i
End With

When one or all checkboxes are checked, I would like to 'collect' them to further manipulate the data.

Any help would be greatly appreciated.

Thanx.

Kim

if you are talking about adding the checked items to the collection, then the code might look something like:

Dim xItem As ListItem
Dim cCol As Collection
Set cCol = New Collection
For Each xItem In listview1.ListItems 'loop through each item in the listview
If xItem.Checked Then 'check for selected item
cCol.Add xItem.Text, xItem.Text 'add to the collection
End If
Next

and to get the selected item from the collection

Dim i As Integer
For i = 1 To cCol.Count
MsgBox cCol.Item(i)
Next

kimt
10-24-2004, 08:36 AM
Many thanx, Duane. Appreciate your help.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum