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 Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

listview delete row selected

Status
Not open for further replies.

vttech

Technical User
Jan 28, 2006
297
US
using vb.net 2005

used the following code to create a listview item


Code:
Private Sub btnItalianSub_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnItalianSub.Click
        Dim dblPrice As Double = 4.99
        CalculateTotals(dblPrice)
        Dim lvItem As ListViewItem = lsvScreen.Items.Add("Italian Sub")
        lvItem.SubItems.Add(dblPrice)
End Sub


this part worked great but when I tried to delete and item that has been selected in the listview with this code

Code:
Private Sub btnDelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDelete.Click
        lsvScreen.Items.Remove(lsvScreen.SelectedItems)
End Sub


vb.net states

Error 1 Value of type 'System.Windows.Forms.ListView.SelectedListViewItemCollection' cannot be converted to 'System.Windows.Forms.ListViewItem'.

what is the error telling me? and how can I accomplish my goal of deleting the item that is selected in the listview?

Newbie in search of knowledge
 
figured it out I needed to change to

ListView1.SelectedItems(0)

Newbie in search of knowledge
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top