Passing selection from a listview to a listbox

ninjaimp

Well-known member
Joined
Jun 13, 2007
Messages
80
Programming Experience
1-3
I have a listview which is populated with values from a data base. What i am trying to do is select an item from the listview via a checkbox and then have that value displayed in a listbox. But everytime all that is displayed in the list box is:

(Collection)


The code i am using to populate the listbox is:

lstResults.Items.Add(ListView1.SelectedItems)


I wondered if anyone had any ideas?

Regards
 
many thanks for your response

tried what you suggested but it doesnt appear to add anythng to the lstresults listbox at all!

Is there something im missing?

cheers
 
I have started to get the result i want, but its not perfect.

the new code im using is:

VB.NET:
For Each Item As Object In ListView1.CheckedItems
            lstResults.Items.Add(Item.ToString)


        Next

Now what i get written to the listbox is:

ListViewItem: {12}


With 12 being the value of the first column in the listbox, but all i want to e returned is the 12, and not all the other bits.

I wondered if anyone knew where i was going wrong?
 
Item isn't Object type, it's type is ListViewItem. Now you suddenly have a lot more options than ToString method.
 

Latest posts

Back
Top