0

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

2
Contributors
6
Replies
7
Views
9 Years
Discussion Span
Last Post by Jx_Man
0

yes, the checkbox is true and this is how the selection is made on the listview.

0

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

the new code im using is:

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?

0

Just a little wrong :

For Each Item As Object In ListView1.CheckedItems
        lstResults.Items.Add(Item.Text)
Next
0

hi

fixed it with this -

For Each itemlist As ListViewItem In ListView1.CheckedItems
            lstResults.Items.Add(itemlist.Text)


        Next

had to change it from 'object' to 'ListViewItem'

i then had the text option

many thanks for your help

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.