Как обратиться к компоненту не по полю name? — Delphi(Делфи)

procedure TForm1.Button1Click(Sender: TObject);
var
  Mas: array [1 .. 3] of TColor;
  TS: TComponent;
  i: integer;
begin
  for i := 1 to 3 do
  begin
    TS := FindComponent('Shape' + IntToStr(i));
    Mas[i] := (TS as TShape).Brush.Color;
    TS := FindComponent('Shape' + IntToStr(i + 3));
    (TS as TShape).Brush.Color := Mas[i];
  end;
end;

Leave a Comment