改变字体色还真不太清楚,不过给你个改变cell背景色的例子 手头没d,都是随手写的,所以有的单词可能拼错了 在getcellparam事件里if column.index=X then //就是你要判断的哪个字段的索引 if dbgrideh.datasource.dataset.fields[column.index].asstring='true' then background:=clxxxx else background:=clxxxx;
在Grid的onDrawColumnCell 事件中写 if ADOTable1.filedbyname('某字段').asboolean = true then begin Grid.Canvas.Font.Color := Clyellow; Grid.DefaultDrawColumnCell(Rect, DataCol, Column, State); end;
procedure TForm1.DBGridEh1GetCellParams(Sender: TObject; Column: TColumnEh; AFont: TFont; var Background: TColor; State: TGridDrawState); begin if column.FieldName = '时间' then if dbgrideh1.datasource.dataset.FieldByName('是否预计').asstring='true' then AFont.Color:= clRed else AFont.Color:= clBlue; end;
手头没d,都是随手写的,所以有的单词可能拼错了
在getcellparam事件里if column.index=X then //就是你要判断的哪个字段的索引
if dbgrideh.datasource.dataset.fields[column.index].asstring='true' then
background:=clxxxx
else
background:=clxxxx;
if ADOTable1.filedbyname('某字段').asboolean = true then
begin
Grid.Canvas.Font.Color := Clyellow;
Grid.DefaultDrawColumnCell(Rect, DataCol, Column, State);
end;
AFont: TFont; var Background: TColor; State: TGridDrawState);
begin
if column.FieldName = '时间' then
if dbgrideh1.datasource.dataset.FieldByName('是否预计').asstring='true' then
AFont.Color:= clRed
else
AFont.Color:= clBlue;
end;