Solved

stop "flashing" while listbox is updated

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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

760 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

21 Experts available now in Live!

Get 1:1 Help Now