Click to See Complete Forum and Search --> : 2 listboxes, databinding and adding from one to another?


KristianH
December 11th, 2002, 12:54 PM
Hi again.

Well I have a listbox, that through databinding has its item added:

Listbox1.DataSource = Dataset1.cbdata.DefaultView
Listbox1.ValueMember = Dataset1.cbdata.cbdataIDColumn.ToString
Listbox1.DisplayMember = Dataset1.cbdata.cbdataColumn.ToString

Now then through a button I want to "Add" one item from Listbox1 to Listbox2, Listbox2 has no databinding...

How is this done (example?) how would I add an item and preserve the valuemember and displaymember etc, so that I can return (example?) the "cbdataID" etc from Listbox2 ?

Regards
/Kristian

Jym
December 13th, 2002, 07:30 AM
.... addbutton.click

Dim x as String

x = listbox1.selectedItem

if x <> "" then listbox2.Items.add(x)

end sub