piojunbabia Posted February 15, 2011 Posted February 15, 2011 (edited) Re: Listview ( remove item ) in vb.net? split from http://www.xtremedotnettalk.com/showthread.php?t=42557, please don't reply to posts more than 30 days old, consider starting a new thread if it is a new problem. PD ListView.Items.Remove removes a ListItem from the list by passing that item to the method, so you can use a For Each loop to loop through all the items and remove the offending ones. Here lvw is a ListView, sName is the text of the item you want to delete, and li is the ListItem class to loop with. Dim li As ListViewItem Dim sName As String For Each li In lvw.Items If li.Text = sName Then lvw.Items.Remove(li) ' If you only want to remove one item with that Text ' you can put an Exit For right here End If Next Hi, is there another way to delete an item in listview similar to the code you gave, but this time deleting a selected item like: Dim li As ListViewItem Dim sName As String For Each li In lvw.Items If [u]li.selectedItem.Index[/u] Then lvw.Items.Remove(li) ' If you only want to remove one item with that Text ' you can put an Exit For right here End If Next the underlined code is the one i want to get. Edited February 15, 2011 by PlausiblyDamp Quote
Administrators PlausiblyDamp Posted February 15, 2011 Administrators Posted February 15, 2011 Re: Listview ( remove item ) in vb.net? Not entirely sure what your question is - are you trying to get the index or the item the index refers to? If you are after the index then what problem are you having? Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.