Results 1 to 2 of 2

Thread: Help with listview ..please

  1. #1
    Guest

    Unhappy

    I'm still not having any luck. Any help is appreciated.


    I'm grabbing text from four texboxes and adding it to a list view with four columns with the click of a button. What is the Syntax for checking if the data I'm about to add to the listview already exists? Here's my current code that adds data to my columns.

    Private Sub cmdAddToListView_Click()

    Set sitem = lstCustomers.ListItems.Add(, , txtFields(1).Text)

    sItem.SubItems(1) = txtFields(2).Text
    sItem.SubItems(2) = txtFields(3).Text
    sItem.SubItems(3) = txtFields(4).Text

    End Sub

  2. #2
    Member
    Join Date
    Sep 1999
    Location
    NSW,Australia
    Posts
    34
    This worked for me, a simple loop to check the sub item with the entry being added. This code removed the matched item in the list view


    For LoopCounter = 1 To ListCount
    lngVariable1 = Val(lstListView.ListItems.Item_(LoopCounter).SubItems(1))
    If lngVariable1 = lngVariable2 Then
    'if there is a match remove the entry in the list box
    lstListView.ListItems.Remove (LoopCounter)
    ListCount = ListCount - 1
    Exit For
    End If
    Next LoopCounter

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