Para estos menesteres me inclino por el uso de la RTTI
Código Delphi
[-]
uses TypInfo;
...
function ExistProperty(AComp: TComponent; APropName: String):Boolean;
var
PropInfo: PPropInfo;
begin
PropInfo := GetPropInfo(AComp.ClassInfo, APropName);
Result:=Assigned(PropInfo);
end;
procedure SetBooleanProperty(AComp: TComponent; APropName: String; AValue: Boolean);
var
PropInfo: PPropInfo;
begin
PropInfo := GetPropInfo(AComp.ClassInfo, APropName);
if PropInfo <> nil then
begin
if PropInfo^.PropType^.Kind = tkEnumeration then
SetOrdProp(AComp, PropInfo, Integer(AValue));
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
var
Control : Array[1..6] of TComponent;
i : Integer;
begin
Control[1] := Label1;
Control[2] := Label2;
Control[3] := Label3;
Control[4] := Edit1;
Control[5] := Edit2;
Control[6] := Edit3;
for i := 1 to 6 do
if ExistProperty(Control[1],'Enabled') then
SetBooleanProperty(Control[1],'Enabled', True);
end;
Saludos cordiales