Click here to Skip to main content
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 8:38am
Edited 4-Jul-12 8: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 690
1 Maciej Los 280
2 Suvendu Shekhar Giri 229
3 Richard Deeming 195
4 Sascha Lefévre 164
0 Sergey Alexandrovich Kryukov 9,678
1 OriginalGriff 9,135
2 Peter Leow 5,082
3 Kornfeld Eliyahu Peter 3,373
4 Maciej Los 2,606

Advertise | Privacy | Mobile
Web04 | 2.8.150327.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