473,503 Members | 8,784 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Flicker when updating Listbox

I have a program that displays constantly changing prices which it
sources from the web once per second. The prices are displayed on a
Listbox (not the best choice but there are good reasons for this).

The Listbox flickers when updating and I can't find a solution on the
net.

Here is the code:

'update Listbox
listPrices.SuspendLayout()
For n = 1 To 20
LineStr = Space(16)

Mid(LineStr, 1, 10) = PriceData(n).ItemID
Mid(LineStr, 13, 4) = PriceData(n).ItemPrice

listPrices.Items(n - 1) = LineStr 'the fault is probably
here
Next n
listPrices.ResumeLayout()

I'm using VB 2005 Express.

Someone with a similar problem was advised to use SuspendLayout and
ResumeLayout and, as you can see, I tried that but it didn't help.

Any ideas?
Jul 14 '08 #1
3 2724
On Jul 14, 10:43*am, Reg Verrin <r...@yingtongtiddleipoyaknow.com>
wrote:
I have a program that displays constantly changing prices which it
sources from the web once per second. The prices are displayed on a
Listbox (not the best choice but there are good reasons for this).

The Listbox flickers when updating and I can't find a solution on the
net.

Here is the code:

'update Listbox
listPrices.SuspendLayout()
For n = 1 To 20
* * * * LineStr = Space(16)

* * * * Mid(LineStr, 1, 10) = PriceData(n).ItemID
* * * * Mid(LineStr, 13, 4) = PriceData(n).ItemPrice

* * * * listPrices.Items(n - 1) = LineStr * 'the fault is probably
here
Next n
listPrices.ResumeLayout()

I'm using VB 2005 Express.

Someone with a similar problem was advised to use SuspendLayout and
ResumeLayout and, as you can see, I tried that but it didn't help.

Any ideas?
What I used to do to handle a similar situation was to override
WndProc and intercept the WM_PAINT messages. Then, I could turn on or
off the painting during the update and then turn it back on
afterwards.

Thanks,

Seth Rowe [MVP]
http://sethrowe.blogspot.com/
Jul 14 '08 #2
"Reg Verrin" <re*@yingtongtiddleipoyaknow.comschrieb
I have a program that displays constantly changing prices which it
sources from the web once per second. The prices are displayed on a
Listbox (not the best choice but there are good reasons for this).

The Listbox flickers when updating and I can't find a solution on
the net.

Here is the code:

'update Listbox
listPrices.SuspendLayout()
For n = 1 To 20
LineStr = Space(16)

Mid(LineStr, 1, 10) = PriceData(n).ItemID
Mid(LineStr, 13, 4) = PriceData(n).ItemPrice

listPrices.Items(n - 1) = LineStr 'the fault is probably
here
Next n
listPrices.ResumeLayout()

I'm using VB 2005 Express.

Someone with a similar problem was advised to use SuspendLayout and
ResumeLayout and, as you can see, I tried that but it didn't help.
listPrices.BeginUpdate
...
listPrices.EndUpdate

?

I think there is no layout with a Listbox.
Armin
Jul 14 '08 #3
Hi Reg,

First off, SuspendLayout won't be doing anything for you - this simply holds
off running layout code (i.e. anchors, docking etc) and as the ListBox isn't
a ContainerControl it won't help with performance.

BeginUpdate/EndUpdate are good candidates, and probably do the same thing as
the Win32 API call of "LockWindowUpdate" which prevents painting until you
tell it otherwise.

One other thing I would suggest: Instead of adding listbox items
one-at-a-time during your For n loop, build up an array of them. Then at
the end of the loop, clear the listbox items and then do a .AddRange call
with your array of new items. That should speed things up a little also.

-Alex
"Reg Verrin" <re*@yingtongtiddleipoyaknow.comwrote in message
news:q2**************************@4ax.com...
>I have a program that displays constantly changing prices which it
sources from the web once per second. The prices are displayed on a
Listbox (not the best choice but there are good reasons for this).

The Listbox flickers when updating and I can't find a solution on the
net.

Here is the code:

'update Listbox
listPrices.SuspendLayout()
For n = 1 To 20
LineStr = Space(16)

Mid(LineStr, 1, 10) = PriceData(n).ItemID
Mid(LineStr, 13, 4) = PriceData(n).ItemPrice

listPrices.Items(n - 1) = LineStr 'the fault is probably
here
Next n
listPrices.ResumeLayout()

I'm using VB 2005 Express.

Someone with a similar problem was advised to use SuspendLayout and
ResumeLayout and, as you can see, I tried that but it didn't help.

Any ideas?

Jul 14 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
3848
by: Marek Mänd | last post by:
This seems an IE issue only: 4253 bytes testcase: http://www.hot.ee/idaliiga/testcases/ieselect/bnlinkingselectinmsie.htm Can one have 1) a mouseover/mouseout element on TBODY 2) change in...
0
1891
by: mp3boss | last post by:
I am updating a string in the format MM:SS every second using the On_Timer event in Access97 by changing the caption of a label. Even though I'm using 8point text, the box sometimes flickers...
4
2168
by: steve | last post by:
ok, ok...obj.suspendlayout/resumelayout. but it isn't helping and i need advice. i have a custom progress bar made from a label control. i manually paint it when the progress changes. i'm drawing a...
3
3501
by: Per Dunberg | last post by:
Hi all, I have to develop a "skinned" application and I have a problem with the graphics. When a form is loaded and displayed there's aways a flicker where all the controls are located on the...
5
10547
by: Charles Law | last post by:
Some of the eagle-eyed amongst you will spot this as a direct follow on from my earlier post about critical timing in .NET. I want to use a ListView to display my output (instead of the sluggish...
5
2418
by: John Veldthuis | last post by:
My code works perfectly 100% when adding items to my ArrayList and updating the listbox. Works perfectly when deleting an item in the ArrayList when it is not the last entry but if it is the last...
0
1291
by: Sladan | last post by:
I have a WebBrowser and I'm using it like this: webSummary.DocumentText = temp; Where temp is a string containing som text and sometimes a <img src = "..." /> tag. If the string contains a...
4
3780
by: Miesha.James | last post by:
Hello. Is there a way you can insert a new row between current rows in a .NET listview? I tried and it was no success. The reason I want to do this is because when the application starts up it...
0
7194
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7070
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7267
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
5566
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4993
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4666
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3160
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
1
729
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
372
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.