有个问题是在Delphi中使用DBGrid时,如何让DBGrid中每一行颜色按照用户自己的意愿控制。
1、 数据表的建立 

2、程序设置;
procedure Tinfo.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect;
  DataCol: Integer; Column: TColumn; State: TGridDrawState);
begin
        if query1.FieldByName(’all’).asstring>40’ then
        begin
                dbgrid1.Canvas.Font.Color:=clred;
                dbgrid1.Canvas.Brush.color:=clyellow;
        end
        else
        begin
                dbgrid1.Canvas.Font.Color:=clblue;
                dbgrid1.Canvas.Brush.color:=clyellow;
                end;
 
        dbgrid1.DefaultDrawColumnCell(rect,datacol,column,state);
end;