Solved

stop "flashing" while listbox is updated

Posted on 2011-09-11
3
293 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
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 85

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

912 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now