delphi的label有个bug对于中文字的caption用autosize总是不准,汉字会被截掉一部分。 解决办法可以如weitao999(涛涛) 所说把label的长度设置长一点。 另一种办法是自己计算汉字的宽度然后再设label.width的值。procedure TForm1.Button1Click(Sender: TObject); begin with label1 do begin canvas.Font.Size := Font.Size; width := canvas.TextWidth(Caption); end; end;
解决办法可以如weitao999(涛涛) 所说把label的长度设置长一点。
另一种办法是自己计算汉字的宽度然后再设label.width的值。procedure TForm1.Button1Click(Sender: TObject);
begin
with label1 do
begin
canvas.Font.Size := Font.Size;
width := canvas.TextWidth(Caption);
end;
end;