Check this simplified sample (the real scenario is different), I want to set tne value of a nested property of a object, in this case set the color of the Font for a TLabel
component to clRed
using RTTI.
var
p : TRttiProperty;
p2: TRttiProperty;
c : TRttiContext;
begin
c := TRttiContext.Create;
try
p := c.GetType(Label1.ClassInfo).GetProperty('Font');
p2 := c.GetType(p.PropertyType.Handle).GetProperty('Color');
p2.SetValue(p.PropertyType.AsInstance,clred); //this line is not working
finally
c.Free;
end;
end;
also i tried
p2.SetValue(Label1,clred);