pixel size of a string with a given font

  • Thread starter Thread starter c_xyTopa
  • Start date Start date
C

c_xyTopa

hi all,

how can i determine a size in pixel of a specific string ("hallo") with
a given Font("Arial", 9.0F, System.Drawing.FontStyle.Regular)?

thank you
 
The Graphics.MeasureString is what you are looking for:

using(Graphics g = (new Control()).CreateGraphics())
{
SizeF sz = g.MeasureString("hallo", SpecificFont);
}
 
Back
Top