CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Mar 2005
    Location
    India
    Posts
    45

    Thumbs up Deleting Multiple Items in Listview

    Hi All,
    could any one tell me how can i delete multiple items in listview control.
    i do this before only for single item.
    Code:
    ListView.Items.RemoveAt(ListView.SelectedItems(0).Index)
    Thanks in Advance
    Regards
    Gurmeet

  2. #2
    Join Date
    Dec 2004
    Posts
    5

    Question Re: Deleting Multiple Items in Listview

    Are you populating the list box from a query if so use the work distinct.

  3. #3
    Join Date
    Mar 2005
    Location
    India
    Posts
    45

    Re: Deleting Multiple Items in Listview

    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
    Last edited by ss_gurmeet; March 11th, 2005 at 07:20 AM.

  4. #4
    Join Date
    Mar 2005
    Location
    India
    Posts
    45

    Re: Deleting Multiple Items in Listview

    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
    Best of Luck
    Regards
    Gurmeet

  5. #5
    Join Date
    Dec 2003
    Location
    St. Cugat - Catalunya
    Posts
    441

    Re: Deleting Multiple Items in Listview

    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:
    Code:
    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
    Last edited by DeepButi; March 14th, 2005 at 05:21 AM.
    Did it help? rate it.

    The best conversation I had was over forty million years ago ... and that was with a coffee machine.

  6. #6
    Join Date
    Mar 2005
    Location
    India
    Posts
    45

    Re: Deleting Multiple Items in Listview

    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

    Regards
    Gurmeet

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured