DbGridEh怎么设奇偶行的颜色不一样呢.......

解决方案 »

  1.   

    三个属性就可以调整:          RowOneColor := clHotLight
              RowTwoColor := clYellow
              RowColorFlat := True
      

  2.   

    给你一个参考:procedure Tmain.bsskindbgrid2DrawColumnCell(Sender: TObject;
      const Rect: TRect; DataCol: Integer; Column: TbsColumn;
      State: TGridDrawState);
    begin
    if adoquery3.RecordCount<1 then exit;
      if adoquery3['单位名称']='合计' then
            begin
               bsskindbgrid2.Canvas.Font.Color:=clblue;
               bsskindbgrid2.Canvas.Brush.color:=clyellow;
            end;
    if adoquery3['单位名称']='应交税金' then
      begin
        bsskindbgrid2.Canvas.Font.Color:=clblue;
        bsskindbgrid2.Canvas.Brush.color:=$00D7DEEE;
      end;if (DataCol=2) and (adoquery3.FieldByName('应收金额').AsFloat<0) then bsskindbgrid2.Canvas.Font.Color:=clred;
    if (DataCol=3) and (adoquery3.FieldByName('应付金额').AsFloat<0) then bsskindbgrid2.Canvas.Font.Color:=clred;
    if (DataCol=4) and (adoquery3.FieldByName('余额').AsFloat<0) then bsskindbgrid2.Canvas.Font.Color:=clred;bsskindbgrid2.DefaultDrawColumnCell(rect,datacol,column,state);end;
      

  3.   

    请问xiaocuo_zrf(女巫手上的猫):
    哪来的三个属性
              RowOneColor := clHotLight
              RowTwoColor := clYellow
              RowColorFlat := True
      

  4.   

    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;
    你看可以了吗?
      

  5.   

    procedure TForm1.DBGridEh1GetCellParams(Sender: TObject; Column: TColumnEh;
      AFont: TFont; val BackGround:TColor; TColumn; State: TGridDrawState);
    begin
      if ADODataSet1.RecNo mod 2=0 then
         begin
             Afont.color:=Clred;
             Background:=Clblue;
         end;
    end;
    可以显示不同字体和颜色,自己试吧
      

  6.   

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