Click here to Skip to main content
Rate this: bad
good
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?
 
Thanks.
 
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
v3
Comments
Sergey Alexandrovich Kryukov at 4-Jul-12 13:42pm
   
Tag it properly. WPF? Forms? Silverlight? ASP.NET? I can try to guess but why?
--SA
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
good
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;
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 320
1 DamithSL 265
2 CPallini 235
3 Maciej Los 190
4 Sergey Alexandrovich Kryukov 184
0 OriginalGriff 5,415
1 DamithSL 4,422
2 Maciej Los 3,820
3 Kornfeld Eliyahu Peter 3,470
4 Sergey Alexandrovich Kryukov 2,911


Advertise | Privacy | Mobile
Web04 | 2.8.141216.1 | Last Updated 4 Jul 2012
Copyright © CodeProject, 1999-2014
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