M
Matt Michael
I have a listview control and a collection object right now that I'm trying
to pass information to and from. Whenever I click on the checkbox, I want
it to remove certain listview items and add them to the collection.
Whenever I uncheck the checkbox, I want to add the items back into the
listview from the collection, and remove them from the collection so I can
do the process multiple times. The listview tag is being used as a key, so
I know which item to remove. It seems that it adds 29 items to the
collection, but then when I go to add them back to the listview, it only
adds 10. What am I doing wrong here?
Dim tmpItem As ListViewItem
If chkOnlyExternal.Checked = True Then
'Remove internal users.
For Each lvitem As ListViewItem In lstUsers.Items
If db.IsInternalUser(lvitem.Tag.ToString) Then
tmpItem = lvitem
lvCollection.Add(lvitem, lvItem.Tag.ToString)
lvitem.Remove()
rmCount += 1
End If
Next
MessageBox.Show("Removed from listview: " & rmCount.ToString)
Else
MessageBox.Show("Collection count: " & lvCollection.Count.ToString)
If lvCollection.Count > 0 Then
For Each lvItem As ListViewItem In lvCollection
lstUsers.Items.Add(lvItem)
lvCollection.Remove(lvItem.Tag.ToString)
addCount += 1
Next
MessageBox.Show("Added back to listview: " & addCount.ToString)
End If
End If
to pass information to and from. Whenever I click on the checkbox, I want
it to remove certain listview items and add them to the collection.
Whenever I uncheck the checkbox, I want to add the items back into the
listview from the collection, and remove them from the collection so I can
do the process multiple times. The listview tag is being used as a key, so
I know which item to remove. It seems that it adds 29 items to the
collection, but then when I go to add them back to the listview, it only
adds 10. What am I doing wrong here?
Dim tmpItem As ListViewItem
If chkOnlyExternal.Checked = True Then
'Remove internal users.
For Each lvitem As ListViewItem In lstUsers.Items
If db.IsInternalUser(lvitem.Tag.ToString) Then
tmpItem = lvitem
lvCollection.Add(lvitem, lvItem.Tag.ToString)
lvitem.Remove()
rmCount += 1
End If
Next
MessageBox.Show("Removed from listview: " & rmCount.ToString)
Else
MessageBox.Show("Collection count: " & lvCollection.Count.ToString)
If lvCollection.Count > 0 Then
For Each lvItem As ListViewItem In lvCollection
lstUsers.Items.Add(lvItem)
lvCollection.Remove(lvItem.Tag.ToString)
addCount += 1
Next
MessageBox.Show("Added back to listview: " & addCount.ToString)
End If
End If