Components doesn't work when the components are connected by elementid in template

Hi,

Like in the subject, when the components are connected to the template via elementid self.components are empty but without elementid is ok.

procedure TForm1.wbtn1Click(Sender: TObject);

var
i: integer;
begin
for i := 0 to Self.ComponentCount - 1 do
begin
Self.wbm1.Lines.Add(Self.Components[i].Name);
end;
end;

The project for repro in attachment. Try with and without elementid set.

ComponentCount.zip (1.6 MB)

When linked to HTML elements, using the component hierarchy is not supported.

Ok ... but ... how can I iterate via components in this case? I need get all components from the form and make some changes.

Keep these components in your own managed list of components.

Can I get some example code on how to do this in this case?

What's problematic with creating a TObjectList and add components as you need to this list?

Ok, I found the solution... thank god ControlCount works.

procedure TForm1.wbtn1Click(Sender: TObject);
var
i: integer;
begin
for i := 0 to Self.ControlCount - 1 do
begin
Self.wbm1.Lines.Add(Self.Controls[i].Name);
end;
end;

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