开发者

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 an开发者_开发百科y 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...


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.


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. ;)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜