0

Hi, thanks for helping.

All this code does is remove the checked items. I want to remove it from one listview box and transfer it to another. Is that possible?

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        With ListView1
            If .CheckedItems.Count > 0 Then
                For checked As Integer = .CheckedItems.Count - 1 To 0 Step -1
                    .Items.Remove(.CheckedItems(checked))
                Next
            End If
        End With
    End Sub

Edited by tusharbhatia: code tags missing

4
Contributors
4
Replies
10
Views
7 Years
Discussion Span
Last Post by jlego
1

See if this helps.

For Each lvItem As ListViewItem In ListView1.Items
            If lvItem.Checked = True Then
                Dim newLvItem As New ListViewItem(lvItem.Text)
                '//-- if it contains subitems. --\\
                'newLvItem.SubItems.Add(lvItem.SubItems(1).Text)
                'newLvItem.SubItems.Add(lvItem.SubItems(2).Text)
                ListView2.Items.Add(newLvItem)
                ListView1.Items.Remove(lvItem)
            End If
        Next
0

ListView1.BeginUpdate()
ListView2.BeginUpdate()
For Each li As ListViewItem In ListView1.CheckedItems
ListView1.Items.Remove(li)
ListView2.Items.Add(li)
Next
ListView1.EndUpdate()
ListView2.EndUpdate()

0

Ok, I understand now. Thanks Codeorder. :)

Edited by tusharbhatia: n/a

0
dim listviewitem as new listviewitem
listviewitem= Me.listview1.SelectedItems.Item(0)
listview2.Items.Add(listviewitem.Clone())

?

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.