Iterate all controls on a TWebForm

This is a question that was raised back in 2022 ( How to loop through ALL controls of a form - WEB / TMS WEB Core - TMS Support Center), but is something I haven't needed until now.

The code I have is:

var
  I: Integer;
  C, S: string;
begin
  for I := 0 to AForm.ComponentCount - 1 do
  begin
    C := AForm.Components[I].ClassName;
    S := AForm.Components[I] .Name;
    if (AForm.Components[I] is TWebDBComboBox) then
      LoadCombo(TWebDBComboBox(AForm.Components[I]));
  end;
end;

It picks up the TWebDataSource, TXDataWebDataset, the fields defined in the dataset, TXDataWebClient and that's it. It doesn't pick up any of the visible controls (TWebDBEdit or TWebDBComboBox).

Any ideas on how to do this?

Thanks.

Controls on your form are accessible with:

var
  i:integer;
begin
  for i := 0 to controlCount - 1 do
  begin
    webmemo1.Lines.Add(controls[i].Name);
  end;
end;
1 Like

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