DbGridEh根据某一个字段的值显示对应底色或字体变化


改变行底色:
procedure TForm1.dggrideh1DrawColumnCell(Sender: TObject;const Rect: TRect; DataCol: Integer; Column: TColumnEh; State: TGridDrawState);
begin
    if(adqry.FieldByName('status').AsBoolean) then
    begin
       dggrideh1.Canvas.Brush.Color:=clRed;         //行底色变色
       dggrideh1.DefaultDrawColumnCell(Rect,DataCol,Column,State);
    end;
end;
改变行字体颜色:
procedure TForm1.dggrideh1DrawColumnCell(Sender: TObject;const Rect: TRect; DataCol: Integer; Column: TColumnEh; State: TGridDrawState);
begin
    if(adqry.FieldByName('status').AsBoolean) then
    begin
       dggrideh1.Canvas.Font.Color:=clMaroon;     //行字体变颜色
       dggrideh1.DefaultDrawColumnCell(Rect,DataCol,Column,State);
    end;
end;

 

 参考:

https://bbs.csdn.net/topics/360262293

posted @ 2018-07-31 09:23  磨叽开发者  阅读(610)  评论(0编辑  收藏  举报