473,836 Members | 1,429 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2361
There are usually several ways, here is one which uses the
SelectedIndexCh amnged Event of the source Listbox. In my Example, I have
named them lb1 and lb2 ( source and destination respectively )

Private Sub lb1_SelectedInd exChanged(ByVal sender As System.Object, ByVal e
As System.EventArg s) Handles lb1.SelectedInd exChanged

Dim o As Object

Dim senderBox As ListBox

senderBox = DirectCast(send er, ListBox)

lb2.Items.Clear ()

For Each o In senderBox.Selec tedItems

lb2.Items.Add(o )

Next

End Sub

-
Terry Burns
http://TrainingOn.net


"Bill Nguyen" <bi************ *****@jaco.com> wrote in message
news:%2******** *******@TK2MSFT NGP09.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******** **********@tk2m sftngp13.phx.gb l...
There are usually several ways, here is one which uses the
SelectedIndexCh amnged Event of the source Listbox. In my Example, I have
named them lb1 and lb2 ( source and destination respectively )

Private Sub lb1_SelectedInd exChanged(ByVal sender As System.Object, ByVal
e As System.EventArg s) Handles lb1.SelectedInd exChanged

Dim o As Object

Dim senderBox As ListBox

senderBox = DirectCast(send er, ListBox)

lb2.Items.Clear ()

For Each o In senderBox.Selec tedItems

lb2.Items.Add(o )

Next

End Sub

-
Terry Burns
http://TrainingOn.net


"Bill Nguyen" <bi************ *****@jaco.com> wrote in message
news:%2******** *******@TK2MSFT NGP09.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******** **********@tk2m sftngp13.phx.gb l...
There are usually several ways, here is one which uses the
SelectedIndexCh amnged Event of the source Listbox. In my Example, I have
named them lb1 and lb2 ( source and destination respectively )

Private Sub lb1_SelectedInd exChanged(ByVal sender As System.Object, ByVal
e As System.EventArg s) Handles lb1.SelectedInd exChanged

Dim o As Object

Dim senderBox As ListBox

senderBox = DirectCast(send er, ListBox)

lb2.Items.Clear ()

For Each o In senderBox.Selec tedItems

lb2.Items.Add(o )

Next

End Sub

-
Terry Burns
http://TrainingOn.net


"Bill Nguyen" <bi************ *****@jaco.com> wrote in message
news:%2******** *******@TK2MSFT NGP09.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******** ********@TK2MSF TNGP14.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******** **********@tk2m sftngp13.phx.gb l...
There are usually several ways, here is one which uses the
SelectedIndexCh amnged Event of the source Listbox. In my Example, I have
named them lb1 and lb2 ( source and destination respectively )

Private Sub lb1_SelectedInd exChanged(ByVal sender As System.Object, ByVal
e As System.EventArg s) Handles lb1.SelectedInd exChanged

Dim o As Object

Dim senderBox As ListBox

senderBox = DirectCast(send er, ListBox)

lb2.Items.Clear ()

For Each o In senderBox.Selec tedItems

lb2.Items.Add(o )

Next

End Sub

-
Terry Burns
http://TrainingOn.net


"Bill Nguyen" <bi************ *****@jaco.com> wrote in message
news:%2******** *******@TK2MSFT NGP09.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
1432
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 selection in the second listbox, the selected item in the first listbox gets deselected. Is there a way to do this? I tried setting selectmode to MULTIPLE, but that option only allows me to select multiple items in one of the listboxes (both of...
1
8952
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 this? eg document.forms.form.list1.selectedIndex='NULL'; ? Where can I find out about all options with regards to the DOM? Thanks,
9
4958
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 been selected. How can I do that? Given the listindex, .selected, .itemsselected, .itemdata properties -- I'm getting confused. (2) I, actually, have two listboxes on the form and I want to ONLY let the user select items in one list. The...
4
1918
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 AutoPostBack="False" BackColor="#ffffff" id="lstCrewChief" runat="server" Rows="1" DataSource="<%# DsCrewChief1 %>" Enabled="True"
0
1589
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 the two other listboxes fill up with choices, one has related versions of that product, and the other has related Categories. Pretty typical stuff. Anyway, when I first designed the page, I used ASP.NET code to fill the values of the Version and...
3
7405
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 Add button, and the selected items will move to the second ListBox. I've been trying to use the ListBox.SelectedObjectCollection with no success. It sounds like the logical thing to use but I can't seem to find
1
6855
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 column and be able to select.deselect all items that I have found. I am using C#.Net Thanks in advance for this
2
6953
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 come across a way to set the listbox value to only 1 at a time, but need multiple toggle buttons to be on their corresponding listbox item values to be selected. Thanks!
3
5055
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 on a form. The first listbox is populated according to command buttons (Command 14 & Command 15) that are clicked by the user (draws data via SQL statement - see code below). The second listbox is populated by user selection from the first listbox. I...
0
9825
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10852
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10556
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9383
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7793
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6980
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5829
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4459
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4022
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.