Delphi DBGridEh根据单元格内容改变某个单元格的背景颜色
程序员文章站
2022-07-13 14:20:30
...
Delphi DBGridEh根据单元格内容改变某个单元格的背景颜色
写在 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;