How can I check if the component has a text property. As I read Rtti will be a good soulution but I did not worked with it before. Any help would be greatly appreciated.
function HasTextProp(aControl: TControl): Boolean;
begin
Result := False;
if (aComponent is ?) then
Exit(True);
end;
var
ObjList: TObjectList<TControl>;
ObjIdx: Integer;
begin
ObjList := TObjectList<TControl>.Create,
ObjList.Add(comp1); {is TcxButton}
ObjList.Add(comp2); {is Tedit}
ObjList.Add(comp3); {is TDateTimeEdit}
for ObjIdx := 0 to lObjList.Count -1 do
begin
if HasTextProp(lObjList.Items[ObjIdx]) then
do something...
end;
end;
For example for published properties:
uses
System.TypInfo;
function HasTextProp(AControl: TControl): Boolean;
begin
Result := IsPublishedProp(AControl, 'Text');
end;