Click here to Skip to main content
15,892,643 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Need for some ui layout manipulations. Is this possible and how? Please help.
EDIT: If I know text size.
Posted
Updated 27-Dec-12 23:49pm
v3
Comments
Sergey Alexandrovich Kryukov 27-Dec-12 17:27pm    
Wow!
—SA
TorstenH. 28-Dec-12 5:58am    
WHY?
what are you trying to do? I expect you to be doing something wrong, so please share some more info about why you want to determine the length of a text.

You are looking in wrong direction. By their nature, strings do not have lengths in in pixels or something like that. Strings are data structures totally abstracted from the way they are presented, such as fonts, colors, rendering styles, geometrical sizes, etc. Those are all some properties of some UI elements, whatever they are.

—SA
 
Share this answer
 
string sta = "Hi This is Word";
Font arialBold = new Font("Garamond", 11.5F);
Size st1 = TextRenderer.MeasureText(sta, arialBold);
float pixcel = st1.Width;
 
Share this answer
 
Comments
[no name] 29-Dec-12 13:45pm    
Excellent!

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