By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,165 Members | 1,403 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,165 IT Pros & Developers. It's quick & easy.

listboxes to select/deselect multiple items

P: n/a
I would like to be able to do the following:

Listbox1/Textbox1 contains list of all items not selected

item A
item B
item D

Listbox2//Textbox2 contains list of all items selected

item C
item E

User then can highlight desired items to select/deselect using the
corresponding arrows (or the like).

Any sample/tip is greatly appreciated.

Bill
Nov 21 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
There are usually several ways, here is one which uses the
SelectedIndexChamnged Event of the source Listbox. In my Example, I have
named them lb1 and lb2 ( source and destination respectively )

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)

Next

End Sub

-
Terry Burns
http://TrainingOn.net


"Bill Nguyen" <bi*****************@jaco.com> wrote in message
news:%2***************@TK2MSFTNGP09.phx.gbl...
I would like to be able to do the following:

Listbox1/Textbox1 contains list of all items not selected

item A
item B
item D

Listbox2//Textbox2 contains list of all items selected

item C
item E

User then can highlight desired items to select/deselect using the
corresponding arrows (or the like).

Any sample/tip is greatly appreciated.

Bill

Nov 21 '05 #2

P: n/a
Thanks Terry;
I'll try this.
Bill

"Terry Burns" <us@ourWebSite.com> wrote in message
news:%2******************@tk2msftngp13.phx.gbl...
There are usually several ways, here is one which uses the
SelectedIndexChamnged Event of the source Listbox. In my Example, I have
named them lb1 and lb2 ( source and destination respectively )

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)

Next

End Sub

-
Terry Burns
http://TrainingOn.net


"Bill Nguyen" <bi*****************@jaco.com> wrote in message
news:%2***************@TK2MSFTNGP09.phx.gbl...
I would like to be able to do the following:

Listbox1/Textbox1 contains list of all items not selected

item A
item B
item D

Listbox2//Textbox2 contains list of all items selected

item C
item E

User then can highlight desired items to select/deselect using the
corresponding arrows (or the like).

Any sample/tip is greatly appreciated.

Bill


Nov 21 '05 #3

P: n/a

Terry;
I would like to remove the selected items from senderBox once they moved to
lb2 in your example. I can seem to make it work I tried to use
..Items.Remove(.selectedindex) but the items remain in the senderBox.

Please help!

Thanks
Bill

"Terry Burns" <us@ourWebSite.com> wrote in message
news:%2******************@tk2msftngp13.phx.gbl...
There are usually several ways, here is one which uses the
SelectedIndexChamnged Event of the source Listbox. In my Example, I have
named them lb1 and lb2 ( source and destination respectively )

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)

Next

End Sub

-
Terry Burns
http://TrainingOn.net


"Bill Nguyen" <bi*****************@jaco.com> wrote in message
news:%2***************@TK2MSFTNGP09.phx.gbl...
I would like to be able to do the following:

Listbox1/Textbox1 contains list of all items not selected

item A
item B
item D

Listbox2//Textbox2 contains list of all items selected

item C
item E

User then can highlight desired items to select/deselect using the
corresponding arrows (or the like).

Any sample/tip is greatly appreciated.

Bill


Nov 21 '05 #4

P: n/a
Is the sender box bound to a dataset or other object ?
--
OHM ( Terry Burns )

http://TrainingOn.net

"Bill Nguyen" <bi*****************@jaco.com> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...

Terry;
I would like to remove the selected items from senderBox once they moved
to lb2 in your example. I can seem to make it work I tried to use
.Items.Remove(.selectedindex) but the items remain in the senderBox.

Please help!

Thanks
Bill

"Terry Burns" <us@ourWebSite.com> wrote in message
news:%2******************@tk2msftngp13.phx.gbl...
There are usually several ways, here is one which uses the
SelectedIndexChamnged Event of the source Listbox. In my Example, I have
named them lb1 and lb2 ( source and destination respectively )

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)

Next

End Sub

-
Terry Burns
http://TrainingOn.net


"Bill Nguyen" <bi*****************@jaco.com> wrote in message
news:%2***************@TK2MSFTNGP09.phx.gbl...
I would like to be able to do the following:

Listbox1/Textbox1 contains list of all items not selected

item A
item B
item D

Listbox2//Textbox2 contains list of all items selected

item C
item E

User then can highlight desired items to select/deselect using the
corresponding arrows (or the like).

Any sample/tip is greatly appreciated.

Bill



Nov 21 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.