Z zhouman Unregistered / Unconfirmed GUEST, unregistred user! 2006-09-29 #1 如何把枚举类型的值返回为字符串类型? 如: type testtype=(p1,p2,p3,p4,p5); 如何把里面其中一个的值转为字符串.
轻 轻舞肥羊 Unregistered / Unconfirmed GUEST, unregistred user! 2006-09-29 #2 uses TypInfo; Caption:=GetEnumName(TypeInfo(testtype), Ord(p1));
T TYZhang Unregistered / Unconfirmed GUEST, unregistred user! 2006-09-29 #3 procedure TForm1.Button1Click(Sender: TObject); type testtype=(p1,p2,p3,p4,p5); const testtypes:array[0..4] of string=('p1','p2','p3','p4','p5'); var t:testtype; begin t:=p4; showmessage(testtypes[integer(t)]); end;
procedure TForm1.Button1Click(Sender: TObject); type testtype=(p1,p2,p3,p4,p5); const testtypes:array[0..4] of string=('p1','p2','p3','p4','p5'); var t:testtype; begin t:=p4; showmessage(testtypes[integer(t)]); end;