刚好碰到 ,顺便试了下,有需要的朋友可以看看。 delphi中遍历枚举类型的方法

uses TypInfo;

type 

 

TOrderType = (otFN,otGR,otSZ);

var

    pi:PTypeInfo;

    i:Integer; ot:TOrderType; s:String;

begin
    pi:=  TypeInfo(TOrderType);
    with GetTypeData(pi)^ do
    begin
      for i := MinValue to MaxValue do
      begin
        s :=   GetEnumName(pi,i);
        case TOrderType(GetEnumValue(pi,s)) of
          otFN : ShowMessage('otFN');
          otGR: ShowMessage('otGR');
          otSZ: ShowMessage('otSZ');
        end;
      end;
    end;

end;

相关文章:

  • 2022-12-23
  • 2021-07-21
  • 2022-12-23
  • 2021-06-06
  • 2021-12-23
  • 2021-05-26
猜你喜欢
  • 2021-11-07
  • 2022-03-05
  • 2021-11-13
  • 2021-06-03
  • 2022-12-23
  • 2022-01-31
  • 2022-12-23
相关资源
相似解决方案