bestlong 怕失憶論壇

 

 

搜索
bestlong 怕失憶論壇 論壇 Delphi QuickReport 報表元件 TQRDBText 中文不會自動換行
樓主: bestlong
go

TQRDBText 中文不會自動換行 [複製鏈接]

Rank: 9Rank: 9Rank: 9

6#
發表於 2010-3-30 21:12 |只看該作者
  1. function ChiWrap(Memo : String;LineLen : Integer) : String;
  2. var
  3.   MemoList, ResultList : Tstrings;
  4.   i : integer;
  5.   WS : WideString;
  6. begin
  7.   MemoList := TStringList.Create;
  8.   ResultList := TStringList.Create;
  9.   try
  10.       MemoList.Text := Memo;
  11.       for i := 0 to MemoList.Count -1 do
  12.       begin
  13.       WS := MemoList[i];
  14.       while Length(WS) > LineLen do
  15.       begin
  16.       ResultList.Add(Copy(WS,0,LineLen));
  17.       WS := Copy(WS,LineLen+1,Length(WS));
  18.       end;
  19.       ResultList.Add(WS);
  20.       end;
  21.       Result := ResultList.Text;
  22.   finally
  23.       MemoList.Free;
  24.       ResultList.Free;
  25.   end;
  26. end;

  27. procedure TForm1.DetailBand1BeforePrint(Sender: TQRCustomBand; var PrintBand: Boolean);
  28. begin
  29.   QRLabel1.Caption := ChiWrap(Table1.FieldByName('ChiDesc').AsString,40);
  30. end;
複製代碼
寫在 QRLabel 的 BeforePrint 事件或該 band 的 BeforePrint 事件都可以

參考來源
http://delphi.ktop.com.tw/board. ... d=100&tid=27799
我是雪龍
http://blog.bestlong.idv.tw
http://www.bestlong.idv.tw
‹ 上一主題|下一主題

Archiver|怕失憶論壇

GMT+8, 2025-5-2 03:35 , Processed in 0.013349 second(s), 10 queries .

Powered by Discuz! X1.5

© 2001-2010 Comsenz Inc.