谢谢!

解决方案 »

  1.   

    偶也遇到这个头痛的问题,来不及研究了,只能这样,我:(Function GetAnchors(Control : TControl ; Parama : String ) : TAnchors;
    begin
       if Control.Anchors = [akLeft] then
         ResultStr := #39+'[akLeft]'+#39
       else if Control.Anchors = [akTop] then
         ResultStr := #39+'[akTop]'+#39
       else if Control.Anchors = [akRight] then
         ResultStr := #39+'[akRight]'+#39
       else if Control.Anchors = [akBottom] then
         ResultStr := #39+'[akBottom]'+#39   else if Control.Anchors = [akLeft,akTop] then
         ResultStr := #39+'[akLeft,akTop]'+#39
       else if Control.Anchors = [akLeft,akRight] then
         ResultStr := #39+'[akLeft,akRight]'+#39
       else if Control.Anchors = [akLeft,akBottom] then
         ResultStr := #39+'[akLeft,akBottom]'+#39   else if Control.Anchors = [akLeft,akTop,akRight] then
         ResultStr := #39+'[akLeft,akTop,akRight]'+#39
       else if Control.Anchors = [akLeft,akTop,akBottom] then
         ResultStr := #39+'[akLeft,akTop,akBottom]'+#39   else if Control.Anchors = [akLeft,akRight,akBottom] then
         ResultStr := #39+'[akLeft,akRight,akBottom]'+#39   else if Control.Anchors = [akLeft,akTop] then
         ResultStr := #39+'[akLeft,akTop]'+#39
       else if Control.Anchors = [akLeft,akTop,akRight] then
         ResultStr := #39+'[akLeft,akTop,akRight]'+#39
       else if Control.Anchors = [akLeft,akTop,akRight,akBottom] then
         ResultStr := #39+'[akLeft,akTop,akRight,akBottom]'+#39
    .....     
    end;
      

  2.   

    case tt of
    aa:astr:='aa';
    bb:astr:='bb';
    cc:astr:='cc';
    ......
    end;
      

  3.   

    getenumname(typeinfo(enumtype),ord(enum));
      

  4.   

    uses typinfo;
    var 
    i:enumtype;
    begin
     for i:=low(enumtype) to high(enumtype) do
       showmessag(getenumname(typeinfo(enumtype),ord(i)));
    end;
      

  5.   

    枚举类型转为字符串类型 
    usesTypInfo;typeTTest = (a, b, c, d, haha, yeah); procedure TForm1.Button1Click(Sender: TObject);varti: PTypeInfo;td: PTypeData;i: Integer;beginti := TypeInfo(TTest);td := GetTypeData(ti);for i := td^.MinValue to td^.MaxValue doListBox1.Items.Add(GetEnumName(ti, i));end;
      

  6.   

    受教。
    对 Control.Anchors 怎么不行拉?
      

  7.   

    那怎么将字符串变成枚举类型的值呢?getenumvalue
      

  8.   

    //type TAnchors = set of TAnchorKind;
    //type TAnchorKind = (akTop, akLeft, akRight, akBottom);
    uses TypInfo;
    var
    i:TAnchorKind ;
    begin
     for i:=low(TAnchorKind ) to high(TAnchorKind ) do
      if i in Control.Anchors  then 
       showmessag(getenumname(typeinfo(TAnchorKind ),i));
    end;