473,287 Members | 1,580 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,287 software developers and data experts.

listboxes to select/deselect multiple items

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
4 2326
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
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

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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Jeffrey Barish | last post by:
I have an application that produces two listboxes. I would like to be able to select one of the items in the first listbox and one of the items in the second listbox. However, when I make my...
1
by: Keiron Waites | last post by:
Hi, I have two select fields with the multiple attribute so you can see all options. When a user clicks on one form, I would like to deselect anything from the other form. Is there a way to do...
9
by: Susan Bricker | last post by:
Hi. I have two questions ... (1) I want to use a Listbox to enable the user to select 1 or many items from the list. However, I'm having trouble figuring out how to find out t which items have...
4
by: bill yeager | last post by:
I have several template columns inside of a datagrid. Inside of these template columns are databound listboxes: <asp:TemplateColumn HeaderText="Crew Chiefs"> <ItemTemplate> <asp:listbox...
0
by: Luis Esteban Valencia | last post by:
have a problem and I'm not sure how to handle/fix it. I have three listboxes on my page. The first listbox has a list of software products. When you select an item in the Products listbox, then...
3
by: Dany P. Wu | last post by:
Hi everyone, One of my Windows forms contain two listbox controls, with Add and Remove buttons between them. The idea is to allow users to select multiple items from one ListBox, click the...
1
by: VBNovice05 | last post by:
I run a search on my database and get items that fit that search in a datagrid. There are checkboxes already for each item. I need to create a select/deselect all checkbox at the top of the...
2
by: 6afraidbecause789 | last post by:
Hi - Has anyone ever used toggle buttons to select items in a listbox? I'd like to put about 24 toggle buttons on an unbound form that select or deselect items in a multiple select listbox. I've...
3
JodiPhillips
by: JodiPhillips | last post by:
Hello everyone, there are many questions and answers relating to moving items between two listboxes here and on the net in general, however, none answer my specific problem. I have two listboxes...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.