delphi7 dbgrideh 表中表颜色显示问题 请教高手

xjjsky105 2016-08-19 02:39:33



子表dbgrideh ongetcellparams事件 代码 如下
With Frm_Data.qry_FaFangdeail do
begin
DayCount:=Trunc(FieldByName('HuanDate').AsDateTime-Now);

if (DayCount=30) or (DayCount<30) then
begin
Background:=clred;
end;
end;

子表dbgrideh 颜色红色显示正常

要求对应主表dbgrideh 也显示红色。就是子表里面有红色的,主表也要直接显示红色。 怎么做???请教高手
...全文
1057 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
lyhoo163 2016-08-22
  • 打赏
  • 举报
回复
一、主DBGridEh1的ondrawcolumncell事件: procedure TShowOldChildFrm.DBGridEh1GetCellParams(Sender: TObject; Column: TColumnEh; AFont: TFont; var Background: TColor; State: TGridDrawState); begin if gdSelected in state then Background:=clred; end; 二、从DBGridEh2的ondrawcolumncell事件: procedure TForm1.DBGrid2DrawColumnCell(Sender: TObject; const Rect: TRect; DataCol: Integer; Column: TColumn; State: TGridDrawState); begin DayCount:=Trunc(FieldByName('HuanDate').AsDateTime-Now); if (DayCount=30) or (DayCount<30) then Background:=clred; end; 三、从DBGridEh2的DBGridEh2CellClick事件: procedure TShowOldChildFrm.DBGridEh2CellClick(Column: TColumnEh); begin DayCount:=Trunc(FieldByName('HuanDate').AsDateTime-Now); if (DayCount=30) or (DayCount<30) then then DBGridEh1.OnGetCellParams:=DBGridEh1GetCellParams else DBGridEh1.OnGetCellParams:=Nil; end; 这样,就能达到你的要求。但是DBGridEh1的变色,必须鼠标点击DBGridEh2,才会反映。
xjjsky105 2016-08-20
  • 打赏
  • 举报
回复
请教大侠赐教
xjjsky105 2016-08-19
  • 打赏
  • 举报
回复
就像上面第三行应该显示红色才对,可是没有显示红色

829

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 非技术区
社区管理员
  • 非技术区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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