Results 1 to 2 of 2

Thread: ListView select all / deselect all?

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2000
    Posts
    1,091
    Hi,

    What would be an easy way to select all and deselect all items in a ListView via a command button?

    Thanks,

    Dan

  2. #2
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986
    Code:
    Private Sub CmdSelectAll_Click()
    'Call our cool function to select all
    SelectAll
    End sub
    
    Private Sub CmdSelectNone_Click()
    'Call our cool function to deselect all
    SelectNone
    End sub
    
    Private Sub CmdInvert_Click()
    'Call our cool function to invert the selection
    InvertSel()
    End sub
    
    Private Function SelectAll()
    For X = 1 To ListView1.ListItems.Count
    ListView1.ListItems.Item(X).Selected = True
    Next X
    ListView1.SetFocus
    End Function
    
    Private Function SelectNone()
    For X = 1 To ListView1.ListItems.Count
    ListView1.ListItems.Item(X).Selected = False
    Next X
    ListView1.SetFocus
    End Function
    
    'Oh and if you need it, an Invert selection:
    'All cool progs have an Invert selection mode :)
    Private Function InvertSel()
    For X = 1 To ListView1.ListItems.Count
    ListView1.ListItems.Item(X).Selected = Not (ListView1.ListItems.Item(X).Selected)
    Next X
    ListView1.SetFocus
    End Function
    will do the job (or was it Jop? ah forget it )

    [Edited by Jop on 09-24-2000 at 12:30 PM]
    Jop - validweb.nl

    Alcohol doesn't solve any problems, but then again, neither does milk.

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