Add items from one to other ListBox.

STOMAR_3

New member
Joined
Jan 17, 2006
Messages
2
Programming Experience
1-3
I have one not so simple problem.
On windows form exist two ListBox-es and one command button, how to programme the button that when I click on he, add only selected items from first Listbox to second Listbox.
I hope that somebody can help me.

Forwarded thankful.
 
I had the same problem and tried the solution. The add and remove fails because in my case the DataSource property for the listboxes is set. What can I do ?
 
adwaitjoshi: In general if you have a databound control and you want to change it's contents, you should update the underlying dataset and then refresh the control.
 
John,
the problem I am facing is this. In order to remove the item from the datatable, i need to know the index of the selected row. If i am looping from the selecteditemscollection, it gives me the index of the item in the selected items array and the wrong item gets removed. If I loop through the entire listbox items collection and check for a selected item, its unnecessary computation. whats the best way to find the selected item in the datatable and then remove it? Also if I am looping through the items using For i = 0 to items.count because I dont remove items from the listbox and the while loop will go for a toss.
Adwait
 
go ask in the Database forum
 
Back
Top