Click to See Complete Forum and Search --> : Deleting Multiple Items in Listview
ss_gurmeet
March 10th, 2005, 09:19 AM
Hi All,
could any one tell me how can i delete multiple items in listview control.
i do this before only for single item.
ListView.Items.RemoveAt(ListView.SelectedItems(0).Index)
Thanks in Advance
Regards
Gurmeet:thumb:
CInners
March 10th, 2005, 12:46 PM
Are you populating the list box from a query if so use the work distinct.
ss_gurmeet
March 11th, 2005, 01:21 AM
No i am not populating the listview with a query. Well thanx for ur reply once again.
Any other Expert Guru of Listview? If exist then plz reply my question.
Regards
Gurmeet:thumb:
ss_gurmeet
March 14th, 2005, 01:50 AM
Hi Experts,
Is there no body who has faced the same problem. I dont think that any expert of vb.net could not faced it. plz Guide me what should i do. Any link on web or post will be appreicated.
Thanks in Advance
DeepButi
March 14th, 2005, 04:18 AM
ss_gurmeet,
I cannot see the problem.
Are you talking about deleting the selected items in a multiselect listview?
The SelectedItems collection is updated for you when you delete an item, so delete allways the first element:
For i = 0 To ListView1.SelectedItems.Count - 1 ' This is evaluated only ONCE :)
MsgBox("Notice the updated count : " & ListView1.SelectedItems.Count.ToString)
MsgBox("Deleting item : " & ListView1.SelectedItems(0).Text)
ListView1.Items.RemoveAt(ListView1.SelectedItems(0).Index)
Next
Hope it helps
ss_gurmeet
March 14th, 2005, 05:57 AM
Hi Deepbuti,
Thank you very much for ur information which u give me (The SelectedItems collection is updated for you when you delete an item, so delete allways the first element). its works fine now.
Best of Luck for ur bright future :thumb:
Regards
Gurmeet :)
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.