字段类型是“真假”型的。在DBGRID中怎么才能显示汉字的“真,假”而不是“TRUE,FALSE”

解决方案 »

  1.   

    建议使用计算字段吧。
    在ttable或tquery控件中加入一个计算字段(calculated);在控件的OnCalcFields事件中写入if fieldbyname('字段名').asboolean then
      fieldbyname('计算字段名').asstring := '真';
      

  2.   

    我在access中定义了一个'是/否'类型的字段,现在我要用SQL语句插入一个值,该如何实现,解决了,另开帖给分。谢谢了
      

  3.   

    你可以使用DATASET的LOOKUP字段!
      

  4.   

    select case Field1 when 1 then '真' when 0 then '假' end as Field1 from MyTable
      

  5.   

    procedure TForm1.ADOQuery1AfterOpen(DataSet: TDataSet);
    begin
      TBooleanField(DataSet.FieldByName('filed1')).DisplayValues := '真;假';
    end;
      

  6.   

    select case when yourfield=true then '真' when yourfield=false then '假' end yourfield from yourtable
      

  7.   

    table的字段的Ongettext事件中写
         if ture then
            text:='真'
         else
            text:='假'
      

  8.   

    procedure TFmShip.DBGrid2DrawColumnCell(Sender: TObject; const Rect: TRect;
      DataCol: Integer; Column: TColumn; State: TGridDrawState);
      var
       AText:String;
    begin
     if Ship_D.Fieldbyname('IsConfirm').AsString='N' then
     begin
      AText:=Column.Field.AsString; 
      DBGrid2.Canvas.Font.Color:=clBlue;
      DBGrid2.Canvas.Font.Style:=[fsBold];
      DBGrid2.Canvas.TextRect(Rect,Rect.Left+2,Rect.Top+
       (Rect.Bottom-Rect.Top-DBGrid2.Canvas.TextHeight(AText)) div 2,AText);
     end;  
      if Column.FieldName='IsBalance' then
      begin
        if UpperCase(Column.Field.DisplayText)='FALSE' then
        begin
       DBGrid2.Canvas.Font.Color:=clBlue;
      DBGrid2.Canvas.Font.Height:=16;
       DBGrid2.Canvas.Font.Style:=[fsBold];
       DBGrid2.Canvas.TextRect(Rect,Rect.left+1,Rect.top+1,'否');
        end;
        if UpperCase(Column.Field.DisplayText)='TRUE' then
        begin
       DBGrid2.Canvas.Font.Color:=clRed;
      DBGrid2.Canvas.Font.Height:=16;
       DBGrid2.Canvas.Font.Style:=[fsBold];
       DBGrid2.Canvas.TextRect(Rect,Rect.left+1,Rect.top+1,'是');
        end;
      end;
    end;