通过Graphics对象的MeasureString方法可以获取字符串的大小,如下:
Graphics graphics = CreateGraphics(); SizeF sizeF = graphics.MeasureString(字符串, new Font("宋体", 9)); MessageBox.Show(string.Format("字体宽度:{0},高度:{1}", sizeF.Width, sizeF.Height)); graphics.Dispose();