Results 1 to 5 of 5

Thread: [RESOLVED] ListView Speed Problem

Threaded View

  1. #1

    Thread Starter
    Lively Member matt3011's Avatar
    Join Date
    May 2002
    Location
    France
    Posts
    82

    Resolved [RESOLVED] ListView Speed Problem

    I am adding ListViewItems to a listView from a SQLDataReader. The problem is that when the number of items grows, the time to add them to the listbox grows exponentially.

    For example, when I add 22 items, the SQL Query takes 40ms and the loop to insert data takes 1300ms
    For 125 items, it's 60ms For the SQL Query and 99 895ms for the loop
    For 250 items, it's 1030ms for the SQL Query and 470 000ms for the loop

    I suspend the layout of the listview during insertion and there is no calculation in the loop, only a few conditions.

    What am I missing ? I can't see anything wrong in my code which goes roughly like this :
    VB Code:
    1. Redim strItem(nbColumn-1)
    2. myListView.SuspendLayout
    3. RS=myConnect.executeReader(Query)
    4. Do While RS.Read
    5.     strItem(0) = rs("id")
    6.     strItem(1) = rs("client")
    7.     ...
    8.     item = New ListViewItem(strItem)
    9.     Select Case strItem(x)
    10.               Case SomeCondition
    11.                    item.BackColor = Color.Black
    12.                    item.ForeColor = Color.White
    13.               Case OtherCondition
    14.                    item.BackColor = Color.Red
    15.                    item.ForeColor = Color.Black
    16.               Case Else
    17.                    item.BackColor = Color.White
    18.                    item.ForeColor = Color.Black
    19.     End Select
    20. myListView.Items.Add(item)
    21. Loop
    22. myListView.ResumeLayout

    Any Help would be great. Thanks
    Last edited by matt3011; Jul 4th, 2005 at 11:20 AM.

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