select case Field1 when 1 then '真' when 0 then '假' end as Field1 from MyTable
procedure TForm1.ADOQuery1AfterOpen(DataSet: TDataSet); begin TBooleanField(DataSet.FieldByName('filed1')).DisplayValues := '真;假'; end;
select case when yourfield=true then '真' when yourfield=false then '假' end yourfield from yourtable
table的字段的Ongettext事件中写 if ture then text:='真' else text:='假'
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;
在ttable或tquery控件中加入一个计算字段(calculated);在控件的OnCalcFields事件中写入if fieldbyname('字段名').asboolean then
fieldbyname('计算字段名').asstring := '真';
begin
TBooleanField(DataSet.FieldByName('filed1')).DisplayValues := '真;假';
end;
if ture then
text:='真'
else
text:='假'
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;