Solved

stop "flashing" while listbox is updated

Posted on 2011-09-11
3
306 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 250 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 250 total points
ID: 36519122
Try using BeginUpdate() and EndUpdate():

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

Or Double Buffer the Form.
0

Featured Post

Industry Leaders: 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

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

734 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