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

vb.net - populate one listbox from another

Hi all just wondering if any one has any idea on the following...

I have two listboxes -

one listbox populated from a database
ListBox1.Items.Add(dr("NAME"))
and the user can collect multiple items.

The next listbox is populated from the selected items from Listbox1.

I'm having trouble populating the Listbox2. Setting the datasource to
Listbox1.SelectedItems works but I want the user to have an option to
clear the Listbox2 -
ListBox1.ClearSelected()
ListBox2.Items.Clear()

But you cannot use this when the Datasource is set.

I have tried this: ListBox2.Items.Add(ListBox1.SelectedItems)

But it doesnt work!!

Thanks!!

Mar 16 '07 #1
1 2023
Try cycling through them and adding them.

For i As Integer = 0 to ListBox1.SelectedIndeces.Count - 1
ListBox2.Items.Add(FieldListBox.SelectedIndeces(i) )
Next i

Robin S.
------------------------

"lolly" <lo********@gmail.comwrote in message
news:11*********************@o5g2000hsb.googlegrou ps.com...
Hi all just wondering if any one has any idea on the following...

I have two listboxes -

one listbox populated from a database
ListBox1.Items.Add(dr("NAME"))
and the user can collect multiple items.

The next listbox is populated from the selected items from Listbox1.

I'm having trouble populating the Listbox2. Setting the datasource to
Listbox1.SelectedItems works but I want the user to have an option to
clear the Listbox2 -
ListBox1.ClearSelected()
ListBox2.Items.Clear()

But you cannot use this when the Datasource is set.

I have tried this: ListBox2.Items.Add(ListBox1.SelectedItems)

But it doesnt work!!

Thanks!!

Mar 16 '07 #2

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

Similar topics

2
by: James Goodman | last post by:
I have a listbox named sub1 on an asp page. I need to fill this list with values from a table. These are selected based upon the selection of a value/s in another listbox. It was suggested that I...
2
by: Wishing I was skiing mom | last post by:
Newbie to VB .NET. My solution contains an item maintenance screen, one of the fields on the screen is an item status, this field is defined as a listbox. The listbox item property contains a...
1
by: Grant Hammond | last post by:
I have a callback function that populates a listbox with a list of file names in a folder. This code came from Terry Kreft/Dev Ashish some years ago. I now want to add another column to the list...
4
by: carl.barrett | last post by:
Hi, I have a list box that displays 2 columns. Behind it sits a query with five columns. These are Column1 (DOB), column2 (a concatenated string of Surname Forname, Title), Column3 (Surname),...
1
by: Devin Wood | last post by:
Hi, I have a page with a ListBox on it, and It's also have a some buttons to populate the ListBox by using JavaScript. I have no problem with populate the listbox using JavaScript. But when the...
3
by: Chris Kettenbach | last post by:
Hello all, Quick question. I have a listbox that is populated by items from a database. When the user select something from the list, I want to populate another listbox based on the selection in...
5
by: Dave | last post by:
Hi All, I have a windows form that contains 2 listboxes and 2 buttons. The listbox on the right is populated by a database routine (This is the easy part). The listbox on the left is populated...
5
by: Arpan | last post by:
In order to populate any server control with data dynamically, is it ALWAYS NECESSARY to either BIND the DataSource to that server control or call the DataBind method of that server control? For...
4
by: Joe Blow | last post by:
Folks, I have read all the posts about databases I could find and I think I need a little more help. I want to take all the items from a field in an access database and use them as list items in...
2
by: dbuchanan | last post by:
I intend to populate a listBox from the database for later use. (the intent for doing this is irrelevant to this questrion) The list box when hidden is never populated. The list box when visible...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
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...

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.