How to get string size with different fonts when drawing picturebo

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
 
M

Maqsood Ahmed

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top