参考文档:http://msdn.microsoft.com/en-us/library/exkzzayx.aspx,http://www.dev102.com/2008/10/09/measure-string-size-in-pixels-c/
方法一:
Graphics graphics = this.CreateGraphics();
SizeF textSize = graphics.MeasureString("How long am I?", this.Font);
缺点:必须先创建Graphics对象
方法二:
Size textSize = TextRenderer.MeasureText("How long am I?", font);
缺点:尺寸不够精确,有一个像素误差
Graphics使用的是GDI+方法,二TextRenderer使用的是GDI方法。Graphics除了上面描述的缺点外,也存在误差计算,可以参考http://www.codeproject.com/Articles/2118/Bypass-Graphics-MeasureString-limitations