就是上一行的记录和下一行的记录底色不同,谢谢

解决方案 »

  1.   

    dgeStore: TDBGridEh
    aqStore: TADOQuery,为TDBGridEh.DataSource.DataSet;
    procedure TfrmEhlib.dgeStoreDrawColumnCell(Sender: TObject;
      const Rect: TRect; DataCol: Integer; Column: TColumnEh;
      State: TGridDrawState);
    begin
      if Odd(aqStore.RecNo + 1) then
      begin
        dgeStore.Canvas.Brush.Color := clCream;
        dgeStore.Canvas.Font.Color := clNavy;
      end;
      if (Rect.Top = (dgeStore.CellRect(dgeStore.Col, dgeStore.row).Top))
          and not (gdFocused in State) then
        dgeStore.Canvas.Brush.Color := $00FFBB95;  dgeStore.DefaultDrawColumnCell(Rect, DataCol, Column, State);
    end;
      

  2.   

    对如同二楼的 OnDrawCell  里写代码。
      

  3.   

    procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect;
      DataCol: Integer; Column: TColumn; State: TGridDrawState);
    Var
     Row : integer;
    begin
     Row := DBGrid1.DataSource.DataSet.RecNo;
     If (Row mod 2)<>0 Then
      DBGrid1.Canvas.Brush.Color:=$00FF0000;
     Else 
      DBGrid1.Canvas.Brush.Color:=$00FFFFC1;
      DBGrid1.DefaultDrawColumnCell(Rect,DataCol,Column,State);
    end;