创建的时候,可以保存这些对象。如果没有保存,那只能查询了。
for i := 0 to ComponentCount - 1 do
if (Components[i] is TLabel) and (TLabel(Components[i]).Caption = 'Your Caption') then begin
Result := TLabel(Components[i]);
Break;
end;
for i := 0 to ComponentCount - 1 do
if (Components[i] is TLabel) and (TLabel(Components[i]).Caption = 'Your Caption') then begin
Result := TLabel(Components[i]);
Break;
end;
TLabel(Components[i]).Caption