DBGrid改变背景色/底色/字体颜色

procedure Tfrm_groupyz_input.DBGrid2DrawColumnCell(Sender: TObject;
  const Rect: TRect; DataCol: Integer; Column: TColumn;
  State1: TGridDrawState);
begin
  inherited;
  with cds1 do
  begin
    if FieldByName('deleted_flag').Value = '1' then
    begin
      DBGrid2.Canvas.Brush.Color := clRed;
      //DBGrid2.Canvas.Font.Color := clRed; //如果改字体颜色用这个
      DBGrid2.DefaultDrawColumnCell(Rect,DataCol,Column,State1);
    end;
  end;
end;

猜你喜欢

转载自blog.csdn.net/qq_33397419/article/details/128836984
今日推荐