begin
with TStringgrid(sender)
do
begin //Modulfehler soll in Rot dargestellt werden
canvas.Brush.color := clBtnFace;
//Zeile 0 in grau
canvas.fillrect(rect);
if arow = 0
then
begin
inc(rect.left, 2);
dec(rect.right, 2);
inc(rect.top, 3);
dec(rect.Bottom, 3);
drawtext(canvas.handle, pchar(cells[acol, arow]), length(cells[acol, arow]), rect, DT_CENTER
or DT_WORDBREAK
or DT_VCENTER);
setMaximalHoehe(TStringgrid(sender));
end
else
begin
inc(rect.left, 4);
dec(rect.right, 4);
inc(rect.top, 3);
dec(rect.Bottom, 0);
if acol = 3
then //Text Rechtsbuendig Zahlen und Datum linksbuendig
drawtext(canvas.handle, pchar(cells[acol, arow]), length(cells[acol, arow]), rect, DT_LEFT
or DT_VCENTER)
else
drawtext(canvas.handle, pchar(cells[acol, arow]), length(cells[acol, arow]), rect, DT_RIGHT
or DT_VCENTER);
end;
end
end;
procedure setMaximalHoehe(Agrid: Tstringgrid);
var
fZeilenHoehe: Integer;
n: Integer;
dummy, maxrect: TRect;
begin
fZeilenHoehe := 0;
for n := 0
to Agrid.colcount - 1
do
begin
dummy.Left := 0;
dummy.Right := Agrid.ColWidths[n];
dummy.Top := 0;
dummy.Bottom := 1;
drawtext(Agrid.canvas.handle, pchar(Agrid.cells[n, 0]), length(Agrid.cells[n, 0]), dummy, DT_CENTER
or DT_WORDBREAK
or DT_CALCRECT);
if (dummy.Bottom - dummy.Top) > fZeilenHoehe
then
begin
fZeilenHoehe := (dummy.Bottom - dummy.Top) + 6;
maxrect := dummy;
end;
end;
Agrid.RowHeights[0] := fZeilenHoehe;
for n := 0
to Agrid.RowCount - 1
do
Agrid.RowHeights[0] := fZeilenHoehe;
end;