|
-
Jul 4th, 2005, 11:08 AM
#1
Thread Starter
Lively Member
[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:
Redim strItem(nbColumn-1)
myListView.SuspendLayout
RS=myConnect.executeReader(Query)
Do While RS.Read
strItem(0) = rs("id")
strItem(1) = rs("client")
...
item = New ListViewItem(strItem)
Select Case strItem(x)
Case SomeCondition
item.BackColor = Color.Black
item.ForeColor = Color.White
Case OtherCondition
item.BackColor = Color.Red
item.ForeColor = Color.Black
Case Else
item.BackColor = Color.White
item.ForeColor = Color.Black
End Select
myListView.Items.Add(item)
Loop
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|