1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64:
| procedure TForm2.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer; Rect: TRect; State: TGridDrawState); begin if (ARow = 1) or (ARow = 0 ) then StringGridAlignment(StringGrid1, Rect, ACol, ARow, taCenter, True);
if ARow > 1 then StringGridAlignment(StringGrid1, Rect, ACol, ARow, taRightJustify, False); if ACol = 6 then StringGridAlignment(StringGrid1, Rect, ACol, ARow, taLeftJustify, False);
end;
formatiert.
Ich drucke dieses stringgrid mit folgende Code:
procedure TForm2.Button1Click(Sender: TObject); var z,zh,s,sb,gr:integer;begin If PrintDialog1.Execute then begin Printer.Title:='Text'; Printer.Canvas.Font.Size:=9; Printer.BeginDoc; gr:=Printer.Canvas.Font.Height*-1 div Printer.Canvas.Font.size; zh:=0; For z:=0 to StringGrid1.RowCount-1 do begin if (z=1) or (z=0) then begin printer.canvas.brush.color:=clsilver; end else begin printer.canvas.brush.color:=clwhite; end; sb:=0; For s:=0 to StringGrid1.ColCount-1 do begin Printer.Canvas.Rectangle(sb,zh,sb+StringGrid1.ColWidths[s]*gr,zh+StringGrid1.RowHeights[z]*gr); Printer.Canvas.TextOut(sb+3*gr,zh+3*gr,StringGrid1.Cells[s,z]); sb:=sb+StringGrid1.ColWidths[s]*gr; end; zh:=zh+StringGrid1.RowHeights[z]*gr; If Printer.PageHeight-zh-StringGrid1.RowHeights[z+1]*gr<0 then begin zh:=0; Printer.NewPage; end; end; Printer.EndDoc; end; end; |