Leaders dynamic_sysop Posted October 1, 2002 Leaders Posted October 1, 2002 Hi can someone please help me with a question on listview in visual basic.net, i have always used vb6 and to remove an item is easy in that for example..... Dim sName as String, i as Integer For i = 1 to listview.listitems.count if listview.listitems(i).text = sName Then listview.listitems.remove(i) Exit For End if Next i this would remove the item from the listview in vb6, but in .net i cant find anyway of removing an item short of if you have selected it:-\ , i make chat clients on msn-chat and use listview as the names list, therefore i cant just make it so an item is removed by clicking on it, i have to have a userparted sub and then compare the user's name with the name in the listview. any help with this would be greatly appreciated ty:) Quote
*Gurus* divil Posted October 1, 2002 *Gurus* Posted October 1, 2002 Each individual ListItem has a Remove method I think. Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
Leaders dynamic_sysop Posted October 1, 2002 Author Leaders Posted October 1, 2002 i've tried all that but no good, even a visual studio.net book doesnt say how to do it, i find this a mighty weird step for microsoft seein how straightforwards listviews were. Quote
*Experts* Bucky Posted October 1, 2002 *Experts* Posted October 1, 2002 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 Quote "Being grown up isn't half as fun as growing up These are the best days of our lives" -The Ataris, In This Diary
Leaders dynamic_sysop Posted October 1, 2002 Author Leaders Posted October 1, 2002 thanx m8 i have been trying to find this out for a long time now and you have fixed my problem, can i ask if there is a place that actually references these things anywhere? cuz i have a teach your self vb.net book and it's basically a waste of time:-\ Quote
*Gurus* divil Posted October 1, 2002 *Gurus* Posted October 1, 2002 Isn't a "teach yourself vb.net book" a contradiction in terms? Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
Leaders dynamic_sysop Posted October 2, 2002 Author Leaders Posted October 2, 2002 yup, but the books dont seem to teach you anything. anyway a few things i have sussed with listview like say...... txtMain.SelectionFont = New Font(txtMain.SelectionFont, FontStyle.Italic) to set a font to itallic, but nothing shows how to change a font from say "Webdings" to "Tahoma" Quote
Leaders dynamic_sysop Posted October 2, 2002 Author Leaders Posted October 2, 2002 txtMain.SelectionFont = New System.Drawing.Font("Webdings", 10.0!) i sussed it Quote
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.