QRLABEL或者QRMEMO怎么实现自动换行
解决方案 »
- 透明设置
- delphi+access中怎样实现它,再线等待!!!!!!!!!!
- ??????????????????????????????????????????????
- Socket通讯问题,多个clientsocket连接到一个serversocket时
- 如何从一个数据库中取数据插入到另一张库中
- 怎样才能到达Delphi编程的最高境界?
- 也是打包的问题,但总觉得怪?????
- 请问delphi中对光驱的控制牵涉到哪几个函数?
- 难道这个问题难为了各位大虾?请问如何在delphi本地数据库(paradox7)的图片字段保存多个图片文件?
- 把所有7月所有没结的贴子都结了;大家认为如何?只要有10个人同意...
- 请教,QRlabel的折行问题?
- 如何在出生日期里查询生日!!!!!!
英文字母的自动换行是按单词的
即 必须有空格 才会自动换或Label1.Caption:='1234566'+#13+'123412341';
procedure row_change(qr: tquickrep; sender: TQRCustomLabel; var Value:
String);
var
SenderWidth: integer;
Line, Part, Final: string;
PosBegin, PosEnd: integer;
i, j: integer;
LastIsEng: boolean;
begin
SenderWidth := Sender.Width;
Part := '';
Final := '';
Line := Value; // 首先删除行内所有换行
while pos(#10, Line) > 0 do
Delete(Line, Pos(#10, Line), 1); // 增加一个回车以方便下面的处理.
if Line[Length(Line)] <> #13 then Line := Line + #13; //循环查找#13,如果找到则处理找到范围内的数据,一直到全部处理完毕
PosBegin := 0;
PosEnd := 0;
for i := 1 to Length(Line) do
begin
if Line[i] = #13 then
begin
PosBegin := PosEnd + 1;
// 这样可以在处理下一段的时候方便地生成开始和结束位置.
PosEnd := i; Part := '';
j := PosBegin;
while j <= PosEnd do
begin
if Line[j] < #128 then
begin // an ascii character
Part := Part + Line[j];
j := j + 1;
LastIsEng := true;
end
else
begin // a DBCS character
Part := Part + Line[j] + Line[j + 1];
j := j + 2;
LastIsEng := false;
end;
// 判断目前是否已经超长
if qr.TextWidth(Sender.Font, part) > SenderWidth then
begin
// 需要剔除刚才的字符,
if LastIsEng then
begin
Delete(Part, Length(Part), 1);
j := j - 1;
end
else
begin
Delete(Part, Length(Part) - 1, 2);
j := j - 2;
end;
//加入回车,
Part := Part + #13;
Final := Final + Part;
Part := '';
end;
end;
Final := Final + Part;
end;
end;
// 删除刚刚加入的回车
if Final[Length(Final)] = #13 then
Delete(Final, Length(Final), 1);
Value := Final;
end;
如:
procedure TListRep_SDForm_PL.QRDBTxtMake_KYPrint(sender: TObject;
var Value: String);
begin
sysdb.row_change(qr_AB, Sender as TQRCustomLabel , Value );
end;