Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Populate a second listbox

Status
Not open for further replies.

lilal111

Technical User
Sep 16, 2008
18
0
0
CA
I am currently using two listboxes (lstbox1 and lstbox2). My objective is to be able to select the same item mulitple times and populate that item in lstbox2 without it being removed from lstbox1

Example

lstbox1 listbox2

apples apples
oranges apples
grapes oranges
grapes

Any Help would be greatly appreciated!!
Thanks!!
 

hi,

Please explain the business case for this requirement. It is a rather unorthodox use if a second control.

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
I know it does not make much sense. It is not a real business case,it is an exercise.

When the add button is clicked, items from lstbox1 should be added and displayed in lstbox2. The user should be able to select as many items as he wants and any number of one item can be added.

thanks.
 

I am all for this kind of stuff: I wonder if/how I can do that? And the most importat word here is 'I'

So, what have you try so far? What worked and what did not work?

Could you show some code with your attempts to do it?

Have fun.

---- Andy
 
Hi there, I have actually figured it out with a bit of research.

Here is a sample of the code I have used to make it work.
This is under the click button for adding to list box
If lstbox1.SelectedIndex > -1 Then
lstbox2.Items.Add(lstbox1.Text)

Else
MessageBox.Show("Please Select an item")
End If

This removes selected items from lstbox2

If lstbox2.SelectedIndex > -1 Then

lstbox2.Items.RemoveAt(lstbox2.SelectedIndex)
Else
MessageBox.Show("Please Select an item")
End If
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top