码迷,mamicode.com
首页 > 编程语言 > 详细

How can I get a name of enumerated value

时间:2015-05-11 00:01:17      阅读:332      评论:0      收藏:0      [点我收藏+]

标签:

For example, if you have the some enum type

TyourEnumType = (One, Two, Three, Four, Five, Six, Seven, Eight, Nine, Ten)

and you want in run-time to get a string with same value for each of them (for example, fill the combobox items with enum values), then you can use the next procedure:
uses TypInfo;

var i: Integer;
begin
  for i := Ord(Low(TyourEnumType)) to Ord(High(TyourEnumType)) do
    Combobox1.Items.Add(GetEnumName(TypeInfo(TyourEnumType), i));
end;

 

How can I get a name of enumerated value

标签:

原文地址:http://www.cnblogs.com/moonwind/p/4493400.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!