select multiple value in listbox A and copy to listbox B

wilmoslee

Member
Joined
Mar 12, 2010
Messages
9
Programming Experience
1-3
Dear all prof,

I have a question here.. pls kindly advise.

I need to design a simple form that allow user to choose the value from Listbox A to Listbox B. For example, in Listbox A, have value A, value B and value C, then user can choose (or highlight value B and value C) and copy into the listbox B.

May i know how can i do this in vb.net? Any reference link?

Many thanks in adv for the great help.
 
You can use ListBox.SelectedItems and you can set the ListBox.SelectionMode of the textbox you which to copy from to either MultiSimple or MultiExtended(Allows shift and ctrl use) this is done if you wish to copy more than one item

e.g.
VB.NET:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        For Each i As Object In ListBox1.SelectedItems
            ListBox2.Items.Add(i)
        Next
    End Sub
 
Back
Top