473,395 Members | 1,797 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,395 software developers and data experts.

Display Items In A Collection In A Listbox

How can I display the items in a collection in a listbox? Then, what is the
code to remove an item from the collection when the item is selected in the
listbox ?

Thanks for all help!!

Maria
Nov 13 '05 #1
4 6422
Maria wrote:
How can I display the items in a collection in a listbox? Then, what is the
code to remove an item from the collection when the item is selected in the
listbox ?


set the RowsourceType property of the listbox to "value list". Have a
function that takes a Collection and returns its members in a properly
separated string; assign that to the RowSource property of the listbox

If you are sure you want to do this on click (when the user navigates
with the keyboard, the Click fires for every row passed, which I
wouldn't expect):

Set the onClick property for the listbox to [Event Procedure] and write
an event handler that removes the item from the collection. Re-filling
the list is an option.

--
Bas Cost Budde, Holland
http://www.heuveltop.nl/BasCB/msac_index.html
I prefer human mail above automated so in my address
replace the queue with a tea
Nov 13 '05 #2
Thank you for responding!

How do I do the following ---

<< function that takes a Collection and returns its members in a properly
separated string; >>

<< event handler that removes the item from the collection. Re-filling the
list is an option.>>

Maria

"Bas Cost Budde" <b.*********@heuvelqop.nl> wrote in message
news:cp**********@news2.solcon.nl...
Maria wrote:
How can I display the items in a collection in a listbox? Then, what is the code to remove an item from the collection when the item is selected in the listbox ?


set the RowsourceType property of the listbox to "value list". Have a
function that takes a Collection and returns its members in a properly
separated string; assign that to the RowSource property of the listbox

If you are sure you want to do this on click (when the user navigates
with the keyboard, the Click fires for every row passed, which I
wouldn't expect):

Set the onClick property for the listbox to [Event Procedure] and write
an event handler that removes the item from the collection. Re-filling
the list is an option.

--
Bas Cost Budde, Holland
http://www.heuveltop.nl/BasCB/msac_index.html
I prefer human mail above automated so in my address
replace the queue with a tea

Nov 13 '05 #3
Maria wrote:
<< function that takes a Collection and returns its members in a properly
separated string; >>
It does depend a bit on what exactly is in the Collection.

Air code:

function EnumColl(coll as collection)as string
dim item as variant
dim cRes as string
for each item in collection
cres=cres & item.value & ";"
next
enumcoll=left(cres,len(cres)-1)
end function
<< event handler that removes the item from the collection. Re-filling the
list is an option.>>


Form is open in design view? Good. Select the listbox, view Properties,
tab Events; choose [Event Procedure] for onClick.
Click the three dot button. If you are presented with three options,
choose the one similar to "write code" (what was that again?)

Put this inside:

yourcollection.remove yourlistbox.listindex

If it doesn't remove the right one, you might have to put

yourcollection.remove yourlistbox.listindex +1

the optional part is then
yourlistbox.rowsource = enumcoll(yourcollection)

--
Bas Cost Budde, Holland
http://www.heuveltop.nl/BasCB/msac_index.html
I prefer human mail above automated so in my address
replace the queue with a tea
Nov 13 '05 #4
rkc
Maria wrote:
How can I display the items in a collection in a listbox? Then, what is the
code to remove an item from the collection when the item is selected in the
listbox ?

Thanks for all help!!

Maria


Look at the RowSourceType Property in help via the Visual Basic IDE.
While your at it, look at the members of VBA.Collection in the Object
Browser which is available from the View menu of the IDE.
Nov 13 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: RandyS | last post by:
I know how to do it in VB6, but that doesn't work in .NET. I am trying to select single or multiple items to load into a collection. -- ..NET Developer in Training
2
by: xzzy | last post by:
I have an app that uses a listbox to display program status messages, and a public function to be used by the solution to update the listbox. I do not know how to make the listbox public so it...
3
by: Prasad | last post by:
Hey All, I am having a little trouble with the ListBox's Items collection property. I am populating the ListBox with data contained in an SQL table using SQLDataAdapter and DataSet. I have...
6
by: Valerian John | last post by:
I have a ListBox webcontrol on an aspx page. Items are added to the ListBox using client-side code. However, when the page is posted back the items are missing/not available. (It is like the...
4
by: Ryan Ternier | last post by:
Thanks for the previous help guys! I got my list box issue working, but now i'm trying to loop through all the items in my page. I want to find each listbox, once I do i strip the ID down to...
3
by: Stimp | last post by:
I have a listbox of values that I populate from a database. I want the user to be able to re-order the list (by first selecting an item and then clicking 'up' or 'down' buttons) and then save...
3
by: Baren | last post by:
Hi! I have a generalized Stored Procedure to get the listbox items in a datareader.Then i am binding the datareader to the listbox. For different pages and different conditions i need to hide...
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...
5
by: Academia | last post by:
(If you've seen this in the drawing NG, sorry. I inadvertently sent it there.) I have a listbox populated with Objects. The Class has a String field that ToString returns. I assume that...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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,...
0
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,...

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.