Re: Slow listbox in Delphi 7 program

Posted by webmaster Guido on April 25, 2006

In Reply to Slow listbox in Delphi 7 program posted by William p15300 on April 24, 2006

I have a listbox in my Delphi 7 program, that I load from a file, and then it contains several thousands of lines of 5 words. I remove words from each line in 4 steps, so that afterwards only the second word of each lines stays. But this terribly slow, because each time Delphi rewrites all of the lines. Is there a trick to modify all the lines and only afterwards display the results when all is done?

Call BeginUpdate before making changes to the items. When all changes are done, call EndUpdate to show the changes on screen.

Example:

ListBox1.Items.BeginUpdate;
for i := 0 to ListBox1.Items.Count -1 do begin
  // Modify item number i
  // Remove or add characters,...
end;
ListBox1.Items.EndUpdate;

For a more detailed explanation, have a look at our tip Speed up the display of Delphi list components

Related Articles and Replies

  • ...