当前位置:编程学习 > 网站相关 >>

quickReport控制自动折行的方法

需要折行的字段下,qrdbtext1的on print 事件下编写如下代码
procedure TFrm_xzcftj_report.QRDBText2Print(sender: TObject;
  var Value: String);
var
  w,i,x,y,j,k:Integer;
  s, t:string;
begin
  W:=Trunc(((TQRShape(sender).Width-2)/12)*2);
  Value:=Trim(Value);
  x:=Length(Value);
  if x>W Then begin
     i := 1;
     j := 0;
     k := 0;
     s := ;
     y:=Trunc(x/w);
     while i <= x do
     begin
       inc(j);
       t := copy(value, i, 1);
       s := s + t;
       if ord(t[1]) >= 160 then inc(k);
       if (j=w) then
       begin
         if odd(k) and (ord(t[1]) >= 160) then
         begin
           s := copy(s, 1, length(s) - 1);
           dec(i);
           k := 0;
         end;
         j := 0;
         s := s + #13;
       end;
       inc(i);
     end;
     value :=s ;
  end;
end
======================================
说明,此时qrdbtext的属性调整为
autosize False
Autostrech False
应把该控件调整的稍大,可以容纳至少2行
[不然折行数据显示不出来]
补充:综合编程 , 安全编程 ,
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,