Solved

Listview refresh slowness problems Visual Basic

Posted on 2004-04-16
13
787 Views
Last Modified: 2012-06-22
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


0
Comment
Question by:bluedragon99
  • 3
  • 3
  • 2
  • +3
13 Comments
 
LVL 27

Expert Comment

by:Dabas
ID: 10846564
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
 
LVL 1

Author Comment

by:bluedragon99
ID: 10846796
Yeah tried Me.Autoredraw = false no help..
0
 
LVL 48

Expert Comment

by:AlexFM
ID: 10847892
Apply LockWindowUpdate to ListBox itself and not the whole window.
0
 
LVL 12

Expert Comment

by:farsight
ID: 10848251
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
 
LVL 27

Expert Comment

by:Dabas
ID: 10848297
I have the feeling we are talking about a VB6 application here
0
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
LVL 27

Expert Comment

by:Dabas
ID: 10848300
oops.
Forget it. Did not read your comment properly!
0
 
LVL 5

Expert Comment

by:Droby10
ID: 10849727
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
 
LVL 19

Expert Comment

by:Melih SARICA
ID: 10849943
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
 
LVL 1

Author Comment

by:bluedragon99
ID: 10856072
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
 
LVL 1

Author Comment

by:bluedragon99
ID: 10856074
btw vb6...
0
 
LVL 19

Accepted Solution

by:
Melih SARICA earned 500 total points
ID: 10856879
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

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

A short article about problems I had with the new location API and permissions in Marshmallow
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now