unit Unit12;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, Grids;
type
TForm12 =
class(TForm)
StringGrid1: TStringGrid;
Timer1: TTimer;
procedure StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
procedure FormCreate(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure FormResize(Sender: TObject);
end;
var
Form12: TForm12;
implementation
uses
Math;
{$R *.dfm}
procedure TForm12.FormCreate(Sender: TObject);
begin
FormResize(Self);
end;
procedure TForm12.FormResize(Sender: TObject);
begin
StringGrid1.RowCount := StringGrid1.Height
div StringGrid1.DefaultRowHeight;
end;
procedure TForm12.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
var
targetGrid: TStringGrid;
begin
targetGrid := Sender
as TStringGrid;
if StrToIntDef(targetGrid.Cells[aCol, aRow], 100) > 100
then
targetGrid.Canvas.Brush.Color := clRed
else
targetGrid.Canvas.Brush.Color := clWhite;
targetGrid.Canvas.FillRect(rect);
targetGrid.Canvas.TextRect(Rect, Rect.Left + 2, Rect.Top + 2, targetGrid.Cells[ACol, ARow]);
end;
procedure TForm12.Timer1Timer(Sender: TObject);
var
i,j: Integer;
begin
for i := StringGrid1.RowCount - 1
downto 2
do
for j := 0
to StringGrid1.ColCount - 1
do
StringGrid1.Cells[j,i] := StringGrid1.Cells[j,i-1];
// Neue Werte simulieren
for I := 0
to StringGrid1.ColCount - 1
do
StringGrid1.Cells[i, 1] := IntToStr(Random(130));
end;
end.