Results 1 to 4 of 4

Thread: [RESOLVED] Listview, refresh or remove

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Nov 2004
    Posts
    72

    Resolved [RESOLVED] Listview, refresh or remove

    How can i prevent entering the same data in a listview control.
    I have a listbox with different names. Depending on the name
    selected all types of data will fill the listview control with columns... .e.g
    address, work number, emplyee id etc... this works fine

    The problem is when I select a different name, the first selection stays in the listview along with the new selection or if I select the same name it adds it again. is there a way to refresh or remove the first choice

    THanks in advance!@

  2. #2
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: Listview, refresh or remove

    You can use FindItem method:
    Code:
    Private Sub Command2_Click()
    Dim i As Integer
    
        ListView1.ListItems.Clear
        
        For i = 1 To 10
            ListView1.ListItems.Add , , "Item" & i
        Next i
        
        If ListView1.FindItem("Item1") Is Nothing Then
            ListView1.ListItems.Add , , "Item1"
        Else
            MsgBox "Item1 already exists." '<<< you shoud get the msgbox
        End If
    
    End Sub

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Nov 2004
    Posts
    72

    Re: Listview, refresh or remove

    Thanks RhinoBull that worked fine.

  4. #4

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