Get string length in pixels

Rectangle r = e.Bounds;
e.Graphics.DrawString(str,this.Font,Brushes.Black,r);

I neet to detect wether string cross the rectangle or not




Answer this question

Get string length in pixels

  • Michael Tsai

    Hi

    You can Mesure a string in Points using the Method MeasureString of the Graphics object.



  • Kyco

    Try using TextRenderer.MeasureText or Graphics.MeasureString if you're using VS2003.


  • Get string length in pixels