Einzelnen Beitrag anzeigen

Blup

Registriert seit: 7. Aug 2008
Ort: Brandenburg
1.429 Beiträge
 
Delphi 10.4 Sydney
 
#17

Re: nochmals StringGridDrawcell

  Alt 28. Aug 2009, 15:22
Machs dir einfach und übersichtlich, erstelle für jede Aufgabe eine eigene Funktion.
Delphi-Quellcode:
function CalcCellColor(AGrid: TStringGrid; ACol, AROw: Integer): TColor;
var
  d1, d2: Double;
begin
  Result := AGrid.Color;
  if ARow > 1 then
  begin
    try
      d1 := StrToFloat(AGrid.Cells[ACol, AROw - 1]);
      d2 := StrToFloat(AGrid.Cells[ACol, AROw]);
      if d1 < d2 then Result := clGreen
      else if d1 > d2 then Result := clRed;
    except
    end;
  end;
end;

// normale Zelle
Canvas.Brush.Color:= CalcCellColor(Sender as TStringGrid, ACol, ARow);
  Mit Zitat antworten Zitat