Hi- I have 2 list boxes, ListBox1 and ListBox2.

ListBox1's item collection is populated with data from a database.
It populates just fine.

ListBox2 is empty

Let's say ListBox1 has an item "Eric" with a value of "1"

So I can select that item in code by:

ListBox1.SelectedValue = "1"

That works just fine.

Now, I want to go through the items in ListBox1 and any selected item I want to copy to ListBox2.

(in this senario nitem is "1")


ListBox1.SelectedValue = nitem

Dim item As ListItem
For Each item In ListBox1.Items
If item.Selected = True Then
ListBox2.Items.Add(item)
End If
Next

So it selects just fine in ListBox1, but doesn't Add the item to ListBox2.

Any ideas? Thoughts? Suggestions?

Nevermind. I figured it out. Needed to wait until ListBox1 was fully databound, then call my code.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.