如题
就是文本长度的象素值

解决方案 »

  1.   

    public int GetStrLength(string strTemp)
         {
    byte[] sarr = System.Text.Encoding.Default.GetBytes(strTemp);
    return sarr.Length;
          }
      

  2.   

    System.Text.Encoding.Default.GetByteCount("your string here")
      

  3.   

    Graphics g = this.CreateGraphics;
    SizeF f = g.MeasureString("String", this.Font);
      

  4.   

    g.MeasureString 可以 测量 字符的实际宽度
      

  5.   

    不全如此。measurestring只能做到winform的部分。楼主说“字体可能被用户修改”,只可能是webform吧,这就比较麻烦,我也碰过同样的问题,参考我的http://community.csdn.net/Expert/topic/3890/3890685.xml,最后sunmast提出了个不是办法的办法。