size in pixes of string and font

The part I dont understand is the YourGraphicsObject. I simply want to pass a string and font. Where does the graphicsobject come from?
 
You need to use a graphics object. For example, if its in the Paint event, you can use e.Graphics.MeasureString(). If outside of the Paint event, you can use Me.CreateGraphics().MeasureString() (assuming youre in a form).
 
If youre creating a graphics object like that, you should be disposing it too.
 
Back
Top