Frequently Asked Component Specific Questions
Options |
Display all FAQ items |
Displaying items 1 to 1 of 1, page 1 of 1
<< previous next >>
TColumnListBox
Fast loading and saving of many items
Fast loading and saving of many items
To add many items to the TColumnListBox, the use of BeginUpdate / EndUpdate will significantly accelerate this.
Example for fast save & load of 5000 items:
procedure TForm4.Button1Click(Sender: TObject); var i,j: integer; li: TListBoxItem; begin with columnlistbox1 do begin Columns.Clear; Columns.Add; Columns.Add; Columns.Add; Columns[0].Width := 80; Columns[1].Width := 80; Columns[2].Width := 80; BeginUpdate; for i := 1 to 5000 do begin li := ListBoxItems.Add; for j := 1 to 3 do begin li.Strings.Add('Col '+inttostr(j)+': Row '+ inttostr(i)); end; end; ListBoxItems.SaveToFile('c:.txt'); EndUpdate; end; end; procedure TForm4.Button2Click(Sender: TObject); begin with columnlistbox1 do begin Columns.Clear; Columns.Add; Columns.Add; Columns.Add; Columns[0].Width := 80; Columns[1].Width := 80; Columns[2].Width := 80; BeginUpdate; ListBoxItems.LoadFromFile('c:.txt'); EndUpdate; end; end;