B
Bill Nguyen
I use the following example (from another post) and it seemed to work fine.
However, when I add the syntax to remove the selected item from the
senderbox, I got error.
senderBox.Items.RemoveAt(senderbox.selectedIndex)
I was told that I need to copy selecteditems to an array and run the For
each routine from the array instead. Can someone please give me some idea
on how to accomplish this?
Thanks a million.
Bill
Private Sub lb1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles lb1.SelectedIndexChanged
Dim o As Object
Dim senderBox As ListBox
senderBox = DirectCast(sender, ListBox)
lb2.Items.Clear()
For Each o In senderBox.SelectedItems
lb2.Items.Add(o)
' to remove from senderBox
senderBox.Items.RemoveAt(senderbox.selectedIndex)
Next
End Sub
However, when I add the syntax to remove the selected item from the
senderbox, I got error.
senderBox.Items.RemoveAt(senderbox.selectedIndex)
I was told that I need to copy selecteditems to an array and run the For
each routine from the array instead. Can someone please give me some idea
on how to accomplish this?
Thanks a million.
Bill
Private Sub lb1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles lb1.SelectedIndexChanged
Dim o As Object
Dim senderBox As ListBox
senderBox = DirectCast(sender, ListBox)
lb2.Items.Clear()
For Each o In senderBox.SelectedItems
lb2.Items.Add(o)
' to remove from senderBox
senderBox.Items.RemoveAt(senderbox.selectedIndex)
Next
End Sub