DrawColumnCell事件中: with (Sender as TDBGridEh) do
begin
Canvas.Font.Color := clBlack;
if (Column.FieldName = '字段名') then
begin
if query.fieldByName('字段名').AsString = '你好' then
begin
Canvas.Brush.Color := clred;
Canvas.FillRect(rect);
Canvas.TextRect(rect, rect.Left, rect.Top, Column.Field.AsString);
end;
end;
end;
begin
Canvas.Font.Color := clBlack;
if (Column.FieldName = '字段名') then
begin
if query.fieldByName('字段名').AsString = '你好' then
begin
Canvas.Brush.Color := clred;
Canvas.FillRect(rect);
Canvas.TextRect(rect, rect.Left, rect.Top, Column.Field.AsString);
end;
end;
end;
if (Column.FieldName = '字段名') and (Column.Field.Value=0) then
begin
Background:=clRed;
end;