Click here to Skip to main content
11,790,816 members (48,973 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: C# Windows .NET Forms font .NET4 , +
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);

This doesn't happen if i change the fontsize in visual studio,but only in code.
How can i avoid this?


Ps:i forgot to said it earlier , i'm working of a Windows form application under .NET Framework 4
Posted 4-Jul-12 7:38am
Edited 4-Jul-12 7:51am
Sergey Alexandrovich Kryukov at 4-Jul-12 13:42pm
Tag it properly. WPF? Forms? Silverlight? ASP.NET? I can try to guess but why?
Member 4311057 at 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

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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;

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

  Print Answers RSS
0 OriginalGriff 385
1 ppolymorphe 339
2 Richard MacCutchan 118
3 Maciej Los 70
4 George Swan 70
0 OriginalGriff 1,154
1 Maciej Los 825
2 KrunalRohit 686
3 ppolymorphe 660
4 CPallini 621

Advertise | Privacy | Mobile
Web02 | 2.8.1509028.1 | Last Updated 4 Jul 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100