现有数量跟最大数量和最小数量比较 改变  计划采购量里面的颜色

解决方案 »

  1.   

    procedure TLForm.sGridDrawCell(Sender: TObject; ACol,
      ARow: Integer; Rect: TRect; State: TGridDrawState);
    begin  if (ARow=行) and(ACol=列) then
      begin
        with sGrid do
        begin
          //设置颜色
          Canvas.Brush.Color := RGB(227,249,248);
          Canvas.TextRect(rect,rect.Left+2,rect.Top+2,Cells[acol, arow]);
          Canvas.FrameRect(Rect);
        end;
      end;
    end;
      

  2.   

    procedure TForm_SumBill0.SHDBGridEh1DrawColumnCell(Sender: TObject;
      const Rect: TRect; DataCol: Integer; Column: TColumnEh;
      State: TGridDrawState);
    var
      Times1,vMax:Real;
    begin
      inherited;if (Column.FieldName='BFCount') or (Column.FieldName='CCCount') then
      begin
        if (QueryBill1.FieldByName('BFCount').AsFloat=0) or (QueryBill1.FieldByName('CCCount').AsFloat=0) then
          Exit;
        Times1:=Abs(QueryBill1.FieldByName('BFCount').AsFloat - QueryBill1.FieldByName('CCCount').AsFloat);
        vMax:= Max(QueryBill1.FieldByName('BFCount').AsFloat , QueryBill1.FieldByName('CCCount').AsFloat);    if (vMax>0) and (Times1/vMax>0.1) then
        begin
          SHDBGridEh1.Canvas.Font.Color:=$002209D2;
        end;
        SHDBGridEh1.DefaultDrawColumnCell(Rect, DataCol, Column, State);
      end;
    end;