Author: Igor Siticov
How to convert font style values into string values?
Answer:
For converting enumerated type values into string we should use the GetEnumName
function from TypInfo unit. Below is example how to perform this action for
TFontStyle type and for our custom type:
1 type2 TOurType = (otFirst, otSecond, otThird, otForth, otFifth, otLast);
3 4 procedure TForm1.Button1Click(Sender: TObject);
5 var6 OT: TOurType;
7 FT: TFontStyle;
8 begin9 // TFontStyle values10 Memo1.Lines.Add('The TFontStyle values:');
11 for FT := Low(TFontStyle) to High(TFontStyle) do12 Memo1.Lines.Add(GetEnumName(TypeInfo(TFontStyle), ord(FT)));
13 14 // The custom TOurType values15 Memo1.Lines.Add('The TOurType values:');
16 for OT := Low(TOurType) to High(TOurType) do17 Memo1.Lines.Add(GetEnumName(TypeInfo(TOurType), ord(OT)));
18 end;