Results 1 to 4 of 4
  1. #1
    Join Date
    Feb 2004
    Posts
    59

    Unanswered: Move Through a ListView

    Hi!

    Does anyone have any idea for coding, to move through a listbox. I essentially need to know the statments for:

    a) set listview to the 1st item (anything like ListView1.BOF?)
    b) move to next listitem
    c) do until Listview is at the end (anything like ListView1.EOF?

    Any Ideas?
    -Matt H-
    www.comperfection.com

  2. #2
    Join Date
    Jan 2005
    Posts
    7
    You say listbox & listview, not quite sure what you wanted...? So, here's some code for listview!

    Code:
        Private Declare Function LockWindowUpdate Lib "user32.dll" _
                (ByVal hwndLock As Long) As Long
         
        Private Const NO_HWND = 0
    
    Private Sub MoveThruListView
    
        Dim lvItem As ListItem
    
    '// Stop the window from updating until we're finished with it
        LockWindowUpdate ListView1.hWnd
    
        For Each lvItem In ListView1.ListItems
    
    '// We now have a reference to a listitem in the listview, show info about it 
    '// or manipulate it etc...
            Msgbox lvItem.Key, vbInformation
        Next
    
    '// Allow list to update again
        LockWindowUpdate NO_HWND
    
    End Sub

  3. #3
    Join Date
    Feb 2004
    Posts
    59

    thanks

    Can I embed an IF statement into what you gave me? I need the if statement to check to see if the currently selected ListView item (sorry bout that earlier) matches a search string. If it does, then nothing happens, if it doesn't, then the item needs to be removed from the list.

    I put this in:

    For Each lvItem in FrmName.ListView1.ListItems
    If frmName.ListView1.SelectedItem <> sID Then 'where sID is the search string
    frmViewOnCall.ListView1.ListItems.Remove
    Else:
    End If
    Next

    It seems to work okay, except for getting to the REMOVE statement. It gives me an error: "argument not optional"... and i'm not sure how to fix. Given what I've mentioned above, does anyone have any ideas on how to fix this?

    Thanks!
    -Matt H-
    www.comperfection.com

  4. #4
    Join Date
    Dec 2004
    Posts
    10
    Doesn't the Remove statement require the number (IE... Remove(indexnum) ) of the item in the list to remove?

Posting Permissions

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