uses Printers;
procedure PrintStringGrid(AGrid: TStringGrid);
var MaxSizes: array of Integer;
column, row, sx, sy, LeftSpace: Integer;
begin
SetLength(MaxSizes, AGrid.ColCount);
for column := 0 to AGrid.ColCount - 1 do
MaxSizes[column] := 0;
for row := 0 to AGrid.RowCount - 1 do
for column := 0 to AGrid.ColCount - 1 do
if Printer.Canvas.TextWidth(Agrid.Cells[column, row]) > MaxSizes[column] then
MaxSizes[column] := Printer.Canvas.TextWidth(Agrid.Cells[column, row]) + 10;
Printer.BeginDoc;
LeftSpace := 10; // sol bosluk
sx := LeftSpace;
sy := 0;
for row := 0 to AGrid.RowCount - 1 do
begin
for column := 0 to AGrid.ColCount - 1 do
begin
Printer.Canvas.TextOut(sx, sy, AGrid.Cells[column, row]);
sx := sx + MaxSizes[column];
end;
sx := LeftSpace;
sy := sy + Printer.Canvas.TextHeight('A') + 2;
end;
Printer.EndDoc;
end;