c# - How to keep ListBox display updated during .Add calls -


I am trying to easily obtain the scrolling list box which will behave in Delphi's TMemo.Add () way .

Using the test code below, it scrolls fine for a while, and then stops at approximately 600 and fails to refresh until it is done.

I've seen the reference to run it to be successful to update the code on a different thread given below like this I use regularly and I'm hoping for a more simple solution I am

 for  (int i = 0; i <10000; i ++) {listBox1.Items.Add (i); ListBox1.Set selected (list box 1. item number - 1, true); Listbox 1 Selected index = -1; This.Refresh (); // overkill but just to make sure ...}  

I would not recommend Doing so, the performance cost of the consecutive result will actually kill the speed, which is about 600 you see - it's just getting too much to handle it

You processed the window's message To do this, you can call application.Refresh during the loop, which keeps it going but once again the value of the display .

A strategy that I have recently seen, which is not simple but effective, is a listback fake, so during adding, you hide the listback and change it in a panel or similar, which is used What you do in a list that looks like a list box When you did swop back in this way you become very smooth, and potentially more visually attractive effects may be worth it at more work.


Comments

Popular posts from this blog

c# - ListView onScroll event -

PHP - get image from byte array -

Linux Terminal Problem with Non-Canonical Terminal I/O app -