我想把表中的数值形字段(只有几个取值,譬如权限:0:管理员,1:普通用户,2:超级用户)在DBGrid里显示时,让他显示汉字,不显示数字,怎么弄,请赐教!!!

解决方案 »

  1.   

    我在字段的OnSetText和OnGetText事件中写代码
    procedure TdmBasicMDForm.RecordStateGetText(Sender: TField;
      var Text: String; DisplayText: Boolean);
    begin
      case Sender.AsInteger of
        1:Text:='普通用户';
        2:Text:='超级用户';
        0:Text:='管理员';
      end;
    end;
    我这么做的,跟本都不能运行运行
    提示:Left side connot be assigned to错误
      

  2.   

    var asinteger :integer;
      asinteger:=FieldByName('user').AsString;
      begin
      case AsInteger of
        1:Text:='普通用户';
        2:Text:='超级用户';
        0:Text:='管理员';
      end;
      

  3.   

    在OnFormShow事件上加上DisplayText方法:
    如: 
      Field[0].DisplayText := 管理员
      Field[1].DisplayText := 普通用户
      Field[2].DisplayText := 超级用户
      

  4.   

    chenam(外面的世界好精彩) :
    老兄:你说的应该加到哪里呀?!!!!
    请赐教!!!