(Gast)
n/a Beiträge
|
AW: Property Readonly setzen - gespeicherte Werte
3. Apr 2017, 14:55
Eventuell hilft sowas:
Delphi-Quellcode:
Function HasProperty(AClass : TObject; APropertyName : String) : Boolean;
Begin
Result := Assigned(GetPropInfo(AClass.ClassInfo, APropertyName));
End;
...
if HasProperty(application.FindComponent(myform).FindComponent(myobject),'ReadOnly') then begin
SetPropValue(application.FindComponent(myform).FindComponent(myobject),'ReadOnly',Readonlystatus);
end;
Oder so (ungetestet, nur hingedaddelt):
Delphi-Quellcode:
uses
TypInfo;
function SetValue(AClass : TObject; AProperty : String; AValue : Variant) : Boolean;
begin
Result := Assigned(GetPropInfo(AClass.ClassInfo, AProperty));
if Result then SetPropValue(AClass, AProperty, AValue);
end;
Benutzung:
Delphi-Quellcode:
var
AClass : TObject;
begin
AClass := application.FindComponent(myform).FindComponent(myobject);
SetValue(AClass,'Visible',True);
SetValue(AClass,'Enabled',False);
SetValue(AClass,'ReadOnly',True);
...
|
|
Zitat
|