theStringname := GetEnumName(Typeinfo(TAlignment),Ord(label1.Alignment));
label1.Alignment := TAlignment(GetEnumValue(TypeInfo(TAlignment),theStringname));
////////////////////////////////
type colours=(red,blue,green)
var colour: colours
begin
colour:='red';
end;
function ColoursToString (C : Colours) : String
begin
Result := GetEnumName (TypeInfo (Colours), Ord (C));
end;
function StringToColours (S : String) : Colours;
var
IntVal : Integer;
begin
IntVal := GetEnumValue (TypeInfo (Colours), S);
if IntVal = -1 then
raise Exception.Create ('Invalid string');
Result := Colours (IntVal);
end;