954,517 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

move and remove listview data

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
tusharbhatia
Newbie Poster
17 posts since Nov 2010
Reputation Points: 10
Solved Threads: 0
 

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
codeorder
Posting Virtuoso
1,913 posts since Aug 2010
Reputation Points: 255
Solved Threads: 384
 


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()

Unhnd_Exception
Posting Pro
570 posts since Nov 2010
Reputation Points: 249
Solved Threads: 201
 

Ok, I understand now. Thanks Codeorder. :)

tusharbhatia
Newbie Poster
17 posts since Nov 2010
Reputation Points: 10
Solved Threads: 0
 
dim listviewitem as new listviewitem
listviewitem= Me.listview1.SelectedItems.Item(0)
listview2.Items.Add(listviewitem.Clone())

?

jlego
Posting Pro
529 posts since Mar 2009
Reputation Points: 31
Solved Threads: 41
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: