遍历枚举类型的值

 1 uses System.TypInfo;
 2 
 3 type
 4   Taa=(aa,bb,cc,dd);
 5 procedure Button1Click(Sender: TObject);
 6 var
 7   piType:PTypeInfo;
 8   s:string;
 9   i:Integer;
10 begin
11   piType := TypeInfo(Taa);
12   with GettypeData(piType)^ do
13   begin
14     for i := MinValue to MaxValue do
15     begin
16       s := GetEnumName(piType,i);
17       ShowMessage(s);
18     end;
19   end;
20 end;

 

posted on 2014-05-28 16:51  天上星  阅读(843)  评论(0)    收藏  举报

导航