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);  
posted @ 2007-02-28 22:21  轻松  阅读(1096)  评论(0编辑  收藏  举报