如何调整标签尺寸以避免裁切? [英] How to resize a label avoiding crop?
问题描述
大家好,
我想知道...我有一个标签,并且正在通过代码更改其字体的大小.
问题是,当字体大小超过25-30pt时,标签内的文本将被裁剪,在我看来,该文本大于分配给标签控件的区域.
这是我更改字体大小的方法:
Hi everyone,
I was wondering...i''ve a label,and i''m changing the size of it''s font by code.
The problem is that when the font size is over 25-30pt the text inside the label is cropped,it seems to me that the text is bigger than the area assigned to the label control.
This is how i change the font size:
label.Font = new Font(fontFamily,fontSize,fontStyle);
如果我在Visual Studio中更改字体大小,而仅在代码中更改字体大小,则不会发生这种情况.
如何避免这种情况?
谢谢.
ps:我忘了说过,我正在.NET Framework 4下运行Windows窗体应用程序.
This doesn''t happen if i change the fontsize in visual studio,but only in code.
How can i avoid this?
Thanks.
Ps:i forgot to said it earlier , i''m working of a Windows form application under .NET Framework 4
推荐答案
问题已解决.
通过代码创建标签时,"AutoSize"属性设置为false.
为避免作物问题,初始化后必须添加以下行:
Problem solved.
when creating a label via code the "AutoSize" properties is set to false.
To avoid the crop problem,after initializing this line have to be added:
label.AutoSize = true;
这篇关于如何调整标签尺寸以避免裁切?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!