BeginUpdate and EndUpdate in Delphi

If you use a Delphi component like a ListBox, Memo, TreeList, ListView,… and you add or modify a lot of items (lines, nodes,…), the component’s performance becomes very slow. This is due to the fact that after each change, it is redrawn on the screen. Solution:

 

 ListBox1.Items.BeginUpdate;
 for i := 1 to 10000 do
 ListBox1.Items.Add('abcd');
 ListBox1.Items.EndUpdate;
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s