Stringlist sort progress bar

2019-08-31 03:33发布

问题:

I have a TListBox that can have a very long stringlist when loaded so I have the operator initiate a Sort by clicking a button. Sometimes the sort can take close to a minute and the operator is left wondering what's happening.

Is there any way I can use a TProgressBar to show that something is happening? If so, how?

OR

Can I Grey (visually disabled) the screen at the start and then color back to white when the sort is completed? If so, how?

Thanks

回答1:

I believe that your fundamental problem is that you are using a visual control as a container. Sorting the list inside the container will have terrible performance. Put 60,000 strings in a TStringList and you'll be able to sort them instantly.

Rather than holding the items in the visual control, you can operate it in virtual mode. That will be the most efficient way to operate.

If you make these changes then you won't need a progress bar.