将dbgrid的owerdraw设为true,相应ondrawdatacell

解决方案 »

  1.   

    在 DBGrid.OnDrawColumnCell(...) 中:
    begin
    if Table.RecNo = 1 then
    DBGrid.Canvas.Font.Color := clyellow
    if  Table.RecNo = 2 then
    DBGrid.Canvas.Font.Color := clwhite;
    if  Table.RecNo = 3 then
    DBGrid.Canvas.Font.Color := clyellow;
    if  Table.RecNo = 4 then
    DBGrid.Canvas.Font.Color := clwhite;
    end;
      

  2.   

    if (Table.RecNo mod 2) = 0 then
    begin    
      dbgrd.Canvas.brush.Color := clYellow;
      dbgrd.DefaultDrawColumnCell(Rect, DataCol, Column, State);
    end
    else
    begin
      dbgrd.Canvas.brush.Color := clWhite;
      dbgrd.DefaultDrawColumnCell(Rect, DataCol, Column, State);
    end;