Lazarus下改变DBGrid记录的颜色,与Delphi不同了。

功能:根据一条记录满足特定条件,使用不同的颜色进行显示。

来源:http://www.aliyagoo.com/blog

主要事件是在PrepareCanvas 不是DrawColumnCell 而且 DefaultDraw不需要设置

procedure TBills.DBGrid1PrepareCanvas(sender: TObject; DataCol: Integer;
   Column: TColumn; AState: TGridDrawState);
 begin
    if RD.Active then

        if RD.Fields[6].AsBoolean then

           DBGrid1.Canvas.Brush.Color:=$00ff0000;
 end;

posted @ 2018-08-02 16:43  Thenext  阅读(287)  评论(0)    收藏  举报