Click here to Skip to main content
13,050,617 members (82,827 online)
Rate this:
Please Sign up or sign in to 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:

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
Updated 4-Jul-12 7:51am
Tag it properly. WPF? Forms? Silverlight? ASP.NET? I can try to guess but why?
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

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
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170713.1 | Last Updated 4 Jul 2012
Copyright © CodeProject, 1999-2017
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