原帖地址:http://blog.csdn.net/hanghwp/archive/2009/09/04/4517387.aspx
1C#中如何获取一个字体的宽度值(像素单位)Graphics g = this.CreateGraphics();
2C#中如何获取一个字体的宽度值(像素单位)SizeF sizeF = g.MeasureString("A"new Font("宋体"9));
3C#中如何获取一个字体的宽度值(像素单位)MessageBox.Show(sizeF.Width + " " + sizeF.Height);
4C#中如何获取一个字体的宽度值(像素单位)g.Dispose();

 

 

1 private void MeasureText1(PaintEventArgs e)
2 {
3     String text1 = "Measure this text";
4     Font arialBold = new Font("Arial"12.0F);
5     Size textSize = TextRenderer.MeasureText(text1, arialBold);
6     TextRenderer.DrawText(e.Graphics, text1, arialBold, 
7         new Rectangle(new Point(1010), textSize), Color.Red);  
8 }
9 

 

 

相关文章: