日期:2014-05-19  浏览次数:20970 次

c#中怎么得到文字的大小
c#中怎么得到文字的大小(象素大小)?例如小五的字,象素高是多少,宽是多少?

------解决方案--------------------
Size size = TextRenderer.MeasureText(text, font):

这个size的Width就是所有像素的宽,Height就是所有像素的高
------解决方案--------------------
Font printFont = new Font( "Courier New ", 9, FontStyle.Bold| FontStyle.Italic);
int TextHeight = Convert.ToInt32(printFont.GetHeight(graph)) + 5;