Solved

Listview refresh slowness problems Visual Basic

Posted on 2004-04-16
13
813 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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
 
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
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…

730 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