在QRdbtextonprint事件中写OnPrint_Event(sender: TObject; var Value: String); var iLen, iWidth: integer; strSource, strTemp : string; //sAddchar begin iWidth := Round(Tcontrol(sender).Width / iWidthP); if Length(Value) <= iWidth then exit; strSource := Value; Value := ''; //sAddchar := ''; sAddchar := sEnter_Key; //·ÀÖ¹½Ø¶Ïºº×Ö¡£ while true do begin iLen := 1; while iLen < iWidth do begin if ord(strSource[iLen]) > 128 then inc(iLen, 2) else Inc(iLen); end; Dec(iLen); strTemp := Copy(strSource, 1, iLen); //加回车 if Value = '' then Value := strTemp else Value := Value + #13 + strTemp; strSource := Copy(strSource, iLen + 1, Length(strSource) - iLen); if Length(strSource) <= iWidth then begin Value := Value + #13 + strSource; exit; end; end;end;
哪位高手救救急!
我如果用QRdbtext,在其中加入回车符,那么扩展到第二页时,它会从纸张的半当中
开始打印(因为我的这一个字段是报表中的最后一个字段,在第一页中处于页中位置)
我现不用QR,用FR了。
http://www.delphibbs.com/delphibbs/dispq.asp?lid=620364
var
iLen, iWidth: integer;
strSource, strTemp : string; //sAddchar
begin iWidth := Round(Tcontrol(sender).Width / iWidthP);
if Length(Value) <= iWidth then exit; strSource := Value;
Value := ''; //sAddchar := ''; sAddchar := sEnter_Key; //·ÀÖ¹½Ø¶Ïºº×Ö¡£
while true do
begin
iLen := 1; while iLen < iWidth do
begin
if ord(strSource[iLen]) > 128 then
inc(iLen, 2)
else
Inc(iLen);
end; Dec(iLen); strTemp := Copy(strSource, 1, iLen); //加回车
if Value = '' then
Value := strTemp
else
Value := Value + #13 + strTemp;
strSource := Copy(strSource, iLen + 1, Length(strSource) - iLen); if Length(strSource) <= iWidth then
begin
Value := Value + #13 + strSource;
exit;
end;
end;end;