TWebComboBox - Optimal loading?

What is the absolute fastest way to populate a TWebComboBox? I've got 500 or so items, and it doesn't seem to matter what I try, it still takes a few seconds.

If I set the HTML directly, it is almost instant, but then I get index out of bounds errors presumably because the TWebComboBox doesn't know it has items now.

I've tried things like cmb.BeginUpdate/cmb.EndUpdate, and cmb.Items.Add vs. cmb.Items.AddStrings but the results are about the same?

I haven't run any tests on TWebLookupCombos but I'm guessing whatever works here would work there as well?

Tested here:

procedure TForm1.WebButton1Click(Sender: TObject);
var
  i: integer;
begin
  console.time('combo');

      webcombobox1.Items.BeginUpdate;
  for i := 0 to 500 do
    begin
      webcombobox1.Items.Add('item ' + i.ToString);
    end;
      webcombobox1.Items.EndUpdate;
  console.timeend('combo');
end;

Takes +/- 4 milliseconds here

1 Like

That's pretty funny!

cmb.BeginUpdate/EndUpdate does nothing but cmb.Items.BeginUpdate/EndUpdate = 1000% improvement. Well, I guess it's good that I asked!

This topic was automatically closed 60 minutes after the last reply. New replies are no longer allowed.