CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: ListView

  1. #1
    Join Date
    Sep 2003
    Location
    Sri Lanka
    Posts
    64

    ListView

    There is a ListBox with several Items.
    I need to Delete all ListItems Text = "*"

    I try with following code

    Code:
    Private Sub RemoveReservedPalletFromLV()
        Dim l As Long
        
        Dim li As MSComctlLib.ListItem
        
        For Each li In lv.ListItems
            If li.Text = "*" Then
                lv.ListItems.Remove (li.Index)
            End If
        Next
    End Sub
    This pice of code gives an error

    "control collection has been modified"

    Can any one help me

    Thank u in Advance

    Dinesh

  2. #2
    Join Date
    Jan 2003
    Location
    7,107 Islands
    Posts
    2,487
    I think you are looking for something like this..
    Code:
    Private Sub RemoveReservedPalletFromLV()
    Dim i&
        
      i = 1
      While i < lvw.ListItems.Count
        If lvw.ListItems(i).Text = "*" Then
          lvw.ListItems.Remove i
        Else
          i = i + 1
        End If
      Wend
      
    End Sub
    Busy

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