How do I copy the selected items from one listbox to another?

I have two listboxes.  I want the selected items in the first box to be copied to the second box on a button click event.

The listbox names are lbFiles and lbDelete.  I want lbFiles to copy to lbDelete.


Private Sub btnRight_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRight.Click
        lbDelete = lbFiles.SelectedItems
End Sub
scross1276Asked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
nickhoggardConnect With a Mentor Commented:
Hi,

Try this

        For Each objItem As Object In lbFiles.SelectedItems
            lbDelete.Items.Add(objItem)
        Next

Cheers

Nick
0
 
scross1276Author Commented:
Worked great man, thanks!!!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.