How to get string size with different fonts when drawing picturebo

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,
I want to draw some strings on a picturebox. The strings has some
different font setting. How can i get the string width and height with
different font setting? Sometimes the string has two or three row. Can i get
a rectangle scope of it? Thanks!

Steven.Xu
 
System.Drawing.Graphics graphics =
System.Drawing.Graphics.FromHwnd(System.IntPtr.Zero);
System.Drawing.SizeF stringSize =
graphics.MeasureString("MyString",font);

SizeF returns string's Height and width according to font. SizeF.Width
and SizeF.Height are floats.

Maqsood Ahmed
Kolachi Advanced Technologies
http://www.kolachi.net
 
Back
Top