Click here to Skip to main content
15,880,427 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
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:

C#
label.Font = new Font(fontFamily,fontSize,fontStyle);



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
Posted
Updated 4-Jul-12 7:51am
v3
Comments
Sergey Alexandrovich Kryukov 4-Jul-12 13:42pm    
Tag it properly. WPF? Forms? Silverlight? ASP.NET? I can try to guess but why?
--SA
Member 4311057 4-Jul-12 14:33pm    
Sorry,i forgot it,i'm doing a Windows Form application using C# and .NET Framework 4.0

1 solution

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;
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900