Results 1 to 2 of 2

Thread: select all listview items

  1. #1

    Thread Starter
    Registered User
    Join Date
    Jul 2001
    Posts
    283

    select all listview items

    i have a listview with about 500 items.
    when i do
    for each item in listview.items
    item.selected = true
    next

    it is very very slow to do that and sometimes crashes the app. what is so inefficient about about this that makes this unwanted behaviour? and is there a better way to select all 500 items?
    thanks...

  2. #2
    Fanatic Member pax's Avatar
    Join Date
    Mar 2001
    Location
    Denmark
    Posts
    840
    Hi

    That's strange. I just tried it on mine and it only took 30 msec's.
    And I don't think there's any other way...Not that I know of, anyway.

    VB Code:
    1. Dim A As Integer = Environment.TickCount
    2. Dim li As ListViewItem
    3.  
    4. For Each li In ListView1.Items
    5.     li.Selected = True
    6. Next
    7.  
    8. MsgBox(Environment.TickCount - A)

    Perhaps it would help if you added a BeginUpdate and an EndUpdate? (Although it didn't do anything for me!)

    VB Code:
    1. Dim A As Integer = Environment.TickCount
    2. Dim li As ListViewItem
    3.  
    4. ListView1.BeginUpdate
    5. For Each li In ListView1.Items
    6.     li.Selected = True
    7. Next
    8. ListView1.EndUpdate
    9. MsgBox(Environment.TickCount - A)
    I wish I could think of something witty to put in my sig...

    ...Currently using VS2013...

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