首页 > 其他 > 详细

获取文字长度

时间:2014-08-27 18:08:58      阅读:220      评论:0      收藏:0      [点我收藏+]

wpf

//获取文字长度
private double MeasureTextWidth(string text, double fontSize, string fontFamily)
{
FormattedText formattedText = new FormattedText(
text,
System.Globalization.CultureInfo.InvariantCulture,
FlowDirection.LeftToRight,
new Typeface(fontFamily.ToString()),
fontSize,
Brushes.Black
);
return formattedText.WidthIncludingTrailingWhitespace;
}

 

winform

    System.Drawing.Size fontSize = System.Windows.Forms.TextRenderer.MeasureText(value, new System.Drawing.Font("Arial", (float)btnDisplay.FontSize));

获取文字长度

原文:http://www.cnblogs.com/metoer/p/3939774.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!