怎么样使满足条件的数据在dbgrid里显示为红色背景?

dawnming 2003-08-19 02:07:02
怎么样使满足条件的数据在dbgrid里显示为红色背景?
...全文
26 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
wdsimon 2003-08-19
  • 打赏
  • 举报
回复
在dbgrid的哦onDrawColumnCell事件里写代码:
如下:
procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect;
DataCol: Integer; Column: TColumn; State: TGridDrawState);
begin
if dbgrid1.DataSource.DataSet.FieldByName('TG011').Value>1000 THEN
//如果某一字段值大于1000
begin
dbgrid1.Canvas.Brush.Color:=clred;
dbgrid1.DefaultDrawColumnCell(rect,datacol,column,state);
end;
end;
lxpbuaa 2003-08-19
  • 打赏
  • 举报
回复
procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject;
const Rect: TRect; DataCol: Integer; Column: TColumn;
State: TGridDrawState);
begin
if {条件} then with TDBGrid(Sender) do
begin
Canvas.Brush.Color := clRed;
DefaultDrawColumnCell(Rect, DataCol, Column, State);
end;
end;

————————————————————————————————————
宠辱不惊,看庭前花开花落,去留无意;毁誉由人,望天上云卷云舒,聚散任风。
————————————————————————————————————

5,388

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧