Listview refresh slowness problems Visual Basic

Hello,

I have a listview control that I use to display about 1200 or so lines of data.  This list is refreshed every 5 seconds.  I was having major problems getting that much data into the listview fast enough because of the listview repainting after each line add.  I am currently using this code here which works "ok".  2 problems here, I have another form that can have about the same amount of data refreshed every 5 seconds, the main form (the one that lockwindow is being used for) puts some of the data into the second form's listview and I haven't been able to get something like LockWindowUpdate secondform.hWnd to work for some reason.  Thats the main problem.  Second problem is that lockwindow updates the entire screen which causes flashing if my prog is minimized or out of view.  Listview stinks but it's a large program and I don't want to swap to something else at this point, how can I lock the second window or speed the display of data up.  It appears it's repainting after each line it's adding, have played with clipcontrols and autoredraw on the form no help.  HELP!!

Private Declare Function LockWindowUpdate Lib "user32" (ByVal hwndLock As Long) As Long

'stop window from refreshing
LockWindowUpdate Me.hWnd

'adding data to listview here

'refresh window once data is added.
LockWindowUpdate 0


LVL 1
bluedragon99Asked:
Who is Participating?
 
Melih SARICAConnect With a Mentor OwnerCommented:
Create an Itemlist AND Set All values in this new virtual Itemlist and then Assign the new itemlist as listviews itemlist. ( sorry about the not in the sentence).

Well in delphi we ave an Assing Procedure in Objects to copy values between same types..

But not sure about VB6.


0
 
DabasCommented:
Hi bluedragon99:
Not know exactly what it is that you are trying to achieve or to show, it is hard to come up with the best solution, but here are a few ideas:
Main idea:
Do not fill the listview with ALL the data. Only with the data that can be shown within the listview. (20 lines?)
If it is important to actually see ALL of the data, so that the user can scroll up and down, you can add a command button named "Refresh with all data". Once the user clicks on it, change the caption of the button to "Continue displaying real time data"
The idea is that either you are in "Display real time data" mode, in which case you make sure you clear the listview and only fill it with the 20 last transactions, or you are in "Show all data" mode, in which case you pause the updates while showing all data collected so far.

Instead of LockWindowUpdate, have you tried using the Me.AutoRedraw method?

Dabas
0
 
bluedragon99Author Commented:
Yeah tried Me.Autoredraw = false no help..
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
AlexFMCommented:
Apply LockWindowUpdate to ListBox itself and not the whole window.
0
 
farsightCommented:
I would try SuspendLayout() and ResumeLayout().
See inside your (hidden) InitializeComponent routine to see how it's used there.
They seem like a .NET near-equivalent to LockWindowUpdate.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemWindowsFormsControlClassSuspendLayoutTopic.asp

'stop control from doing layout
listview1.SuspendLayout()

'adding data to listview here

'let control complete the layout
listview1.ResumeLayout()
0
 
DabasCommented:
I have the feeling we are talking about a VB6 application here
0
 
DabasCommented:
oops.
Forget it. Did not read your comment properly!
0
 
Droby10Commented:
2 things:

listview is known to be slow for updates, have you tried setting visible to false before the data changes and back to true afterwards?  that's the typical suggestion for that scenario (i'm not a huge fan of it, but i've read that response a number of times and it seems to work)...i can't see it being that much better than turning off updates, though.

the other is that are you certain that the visualization/population set part of it is the bottleneck and not the population retrieval?  ie. an expensive database query.

0
 
Melih SARICAOwnerCommented:
Create an Itemlist Not Set All values in this new virtual Itemlist and then Assign the new itemlist as listviews itemlist

U ll see it very very fast ..

0
 
bluedragon99Author Commented:
Sounds interesting can you explain?

Create an Itemlist Not Set All values in this new virtual Itemlist and then Assign the new itemlist as listviews itemlist

U ll see it very very fast ..
0
 
bluedragon99Author Commented:
btw vb6...
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.