定义了一个枚举类型:
Type
   M=(one,two,three);
然后在begin里如何将它付值给一个字符串或Edit1.Text等字符串类型的呀?
请各位帮忙,谢谢.

解决方案 »

  1.   

    好像是这个
    function GetEnumName(TypeInfo: PTypeInfo; Value: Integer): string;
    怎么用自己看帮助
      

  2.   

    type
      TM=(one,two,three,four,five,six);
      TS = set of TM;procedure TForm1.Button1Click(Sender: TObject);
    var
      T: TM;
      S: TS;
    begin
      S := [one,two,three];
      for T := Low(T) to High(T) do
        if T in S then 
           Edit1.Text:=GetEnumName(TypeInfo(TM), Ord(T));
    end;
      

  3.   

    我用的是集合的办法。有更简单的方法:
    type
      TM=(one,two,three);procedure TForm1.Button1Click(Sender: TObject);
    var
      T: TM;
    begin 
       T:=two;
       Edit1.Text:=GetEnumName(TypeInfo(TM), Ord(T));//two
    end;