listview code error

stingray

New member
Joined
Jun 28, 2007
Messages
1
Programming Experience
Beginner
im trying to make this code work...

Private Sub lstBunsView_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lstBunsView.SelectedIndexChanged
Dim sValue As String
sValue = lstBunsView.Items(lstBunsView.SelectedItems)
ListBox3.Items.Add(sValue)
End Sub


however, the "SelectedItems" part is an error and i do not know where has gone wrong. please kindly enlighten me. i really need som help.
 
The selecteditems function returns a collection. You need to have an integer or key string to access a listviewitem the way you are trying to. Here a little snippet that should get you on the right track.

VB.NET:
Expand Collapse Copy
        Dim sValue As String
        For Each lvi As ListViewItem In lstBunsView.SelectedItems
            sValue = lvi.Text
            listbox3.items.add(sValue)
        Next
 
Back
Top