?
Solved

stop "flashing" while listbox is updated

Posted on 2011-09-11
3
Medium Priority
?
311 Views
Last Modified: 2012-05-12
vs 2008:  I have a form with a listbox control and timer control.  Every 5 seconds the app downloads data from a database to update a listbox with potential new data.  Everytime that happens (new data or not) the form "blinks" while the listbox is re-loaded.  How can I stop this?
0
Comment
Question by:dhenderson12
[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 Comments
 
LVL 37

Accepted Solution

by:
Neil Russell earned 1000 total points
ID: 36519011
Why reload the listbox if there is no new data?
0
 
LVL 40
ID: 36519082
As pointed to by Neilsr, you should check for new data before updating the ListBox, and update it only when needed. There is surely a way to get a count of the number of items. Just check that the count has changed.

The reason for the blink is that when an item is added to a ListBox (or ComboBox), it automatically becomes the selection. If some event such as the SelectedIndexChanged and SelectedValueChanged event is programmed to to something in the interface, it gets called for every item in the list.

In order to prevent that, you need to stop the event from triggering for a while. Here is the way to do it with the SelectedIndexChanged.
RemoveHandler ListBox1.SelectedIndexChanged, AddressOf ListBox1_SelectedIndexChanged
     'The event won't trigger, you can fill ListBox1 here
     'Once done, reactivate the event with
AddHandler ListBox1.SelectedIndexChanged, AddressOf ListBox1_SelectedIndexChanged

Open in new window

0
 
LVL 86

Assisted Solution

by:Mike Tomlinson
Mike Tomlinson earned 1000 total points
ID: 36519122
Try using BeginUpdate() and EndUpdate():

        ListBox1.BeginUpdate()
        ' ... update data ...
        ListBox1.EndUpdate()

Or Double Buffer the Form.
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

752 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