The following code will work.
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.GetValue(Label1).AsObject,clred); //this line now works. finally c.Free; end; end;
You need to get the embedded font from the label. TRttiProperty deals with types, not instances. You need to call GetValue() or SetValue() to work with the instance.
Your source code referred to a type, not an instance.
source share