请问如何显示
type
  TStatus = {Active, Passive,Waiting};中的字符信息即Active, Passive,Waiting,而不是0,1,2

解决方案 »

  1.   

    uses
      TypInfo;type
      TStatus = (Active, Passive,Waiting); 
      
    procedure TForm1.Button1Click(Sender: TObject);
    var
      ti: PTypeInfo;
      td: PTypeData;
      i: Integer;
    begin
      ti := TypeInfo(TTest);
      td := GetTypeData(ti);
      for i := td^.MinValue to td^.MaxValue do
        ListBox1.Items.Add(GetEnumName(ti, i));
    end;
      

  2.   

    uses 
      TypInfo; type 
      TStatus = (Active, Passive,Waiting);  
       
    procedure TForm1.Button1Click(Sender: TObject); 
    var 
      ti: PTypeInfo; 
      td: PTypeData; 
      i: Integer; 
    begin 
      ti := TypeInfo(TStatus); 
      td := GetTypeData(ti); 
      for i := td^.MinValue to td^.MaxValue do 
        ListBox1.Items.Add(GetEnumName(ti, i)); 
    end;