如何让DBGRID隔行显示背景色(兰色)?如何让DBGRID中行间距增大?

解决方案 »

  1.   

    procedure TPersonForm.DBGrid1DrawColumnCell(Sender: TObject;
      const Rect: TRect; DataCol: Integer; Column: TColumn;
      State: TGridDrawState);
    begin
    //change the color mode of this DBGrid
    //inherited;
    With DbGrid1 do
    begin
      if ((State = [gdSelected]) or (State = [gdSelected,gdFocused])) then
        begin
        Canvas.Font.Color := clYellow;
        Canvas.Brush.Color := clNavy;
        end
      else
        begin
         //showmessage(inttostr(cds1.RecNo));
        if CDS1.RecNo mod 2 <> 0 then Canvas.Brush.Color := clWhite
        else Canvas.Brush.Color := clskyblue;
        end;
      DefaultDrawColumnCell(Rect,DataCol,Column,State);
    end;
    end;