GDI+ 取得文本的宽度和高度

string   s=this.textBox1.Text.Trim();  
  float   w=0;  
  float   h=0;  
  Graphics   g=Graphics.FromHwnd(this.Handle);  
  Font   myf=new   Font("宋体",15);  
  StringFormat   sf=new   StringFormat(StringFormat.GenericTypographic);  
    SizeF   size=g.MeasureString(s,myf,1000,sf);  
原文地址:https://www.cnblogs.com/sun_moon_earth/p/660212.html