473,569 Members | 2,793 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.Susp endLayout()
For n = 1 To 20
LineStr = Space(16)

Mid(LineStr, 1, 10) = PriceData(n).It emID
Mid(LineStr, 13, 4) = PriceData(n).It emPrice

listPrices.Item s(n - 1) = LineStr 'the fault is probably
here
Next n
listPrices.Resu meLayout()

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 2725
On Jul 14, 10:43*am, Reg Verrin <r...@yingtongt iddleipoyaknow. 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.Susp endLayout()
For n = 1 To 20
* * * * LineStr = Space(16)

* * * * Mid(LineStr, 1, 10) = PriceData(n).It emID
* * * * Mid(LineStr, 13, 4) = PriceData(n).It emPrice

* * * * listPrices.Item s(n - 1) = LineStr * 'the fault is probably
here
Next n
listPrices.Resu meLayout()

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*@yingtongti ddleipoyaknow.c omschrieb
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.Susp endLayout()
For n = 1 To 20
LineStr = Space(16)

Mid(LineStr, 1, 10) = PriceData(n).It emID
Mid(LineStr, 13, 4) = PriceData(n).It emPrice

listPrices.Item s(n - 1) = LineStr 'the fault is probably
here
Next n
listPrices.Resu meLayout()

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.Begi nUpdate
...
listPrices.EndU pdate

?

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 ContainerContro l it won't help with performance.

BeginUpdate/EndUpdate are good candidates, and probably do the same thing as
the Win32 API call of "LockWindowUpda te" 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*@yingtongti ddleipoyaknow.c omwrote 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.Susp endLayout()
For n = 1 To 20
LineStr = Space(16)

Mid(LineStr, 1, 10) = PriceData(n).It emID
Mid(LineStr, 13, 4) = PriceData(n).It emPrice

listPrices.Item s(n - 1) = LineStr 'the fault is probably
here
Next n
listPrices.Resu meLayout()

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
3856
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 thoise event handler background colors 3) have a specified heighted SELECT element, that doesnt flicker when the event handlers are get called.
0
1896
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 (transparent background changes to light-gray before reverting back to transparent). The text is drawn on top of a rectangle that is on top of a form...
4
2179
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 filled, rounded rectangle twice w/n the label...once to give a light background color, the second time is the show the progress. the third paint...
3
3507
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 form. It seems like the controls erase the background and this cause a flicker everytime a form i loaded. When I hide and show forms that are already...
5
10555
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 RichTextBox), but it flickers madly when I update it. There have been numerous posts about this, but I have found no solution. Enabling...
5
2422
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 entry and you select another index it goes boom!!!. Funny thing is the SelectedIndex Changed routine fires off perfectly and then crash after the...
0
1297
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 link to an image the webbrowser will totally freak out. It will flicker, constantly updating and you can't scroll or anything. Any suggestions how...
4
3807
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 prints a list of id's in the listview window. The window has to be updated every 2seconds and I would need to be able to insert the data...
0
7922
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8119
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7668
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7964
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5509
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5218
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3653
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1209
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
936
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.