fpdragon
fpdragon

Reputation: 1937

c# - fast ListBox data update

I want to display in about 20 lines some text data. Every line can be longer than the size of the form is. In this case the rest of the line should be cut away.

I don't want to have any h or v scroll bar.

Since the ListBox control can deal with my requirements I tried to use it. Everything is working fine but if I have a heavy disk load it can happen that the control begins to flicker and I don't think this has to be. I am updating the data once a second and I always have less then 20 lines of text data. Seems that I'm using the ListBox wrong.

I have the possibility to prepare the data in an other thread as a string or a string array but in every case have to update the whole ListBox. Which technique is the best for filling the ListBox with data? Can I have two buffers which I can toggle to be used with the ListBox?

Hope there is a better solution...

Upvotes: 1

Views: 1250

Answers (2)

Shekhar_Pro
Shekhar_Pro

Reputation: 18430

Try calling SuspendLayout() for the ListBox before adding data to it and then call ResumeLayout() on the ListBox. You may lose that flicker a bit.

Upvotes: 2

Core_F
Core_F

Reputation: 3442

You could either create a databinding and then just update the binding, that should work better. A cheap way would be to change the visibility of the listbox and make it invisible at the beginning and visible at the end. Cheap, but should work. ;)

Upvotes: 0

Related Questions