Text width

  • Thread starter Thread starter Mike
  • Start date Start date
M

Mike

Is there a way to determine how long (in twips) a given text string in a
given font will be on the screen?
 
System.Drawing.Graphics g = Control.CreateGraphics();

int intStringLength = g.MeasureString(string text, System.Drawing.Font
font);

Regards,

éric
 
What is "Control" in this example? The CreateGraphics() method of the
TextBox, Button, and ListBox controls is apparently not supported in the
Compact Framework.
 
I think the form control supports CreateGraphics
To measure a string any control will do.
éric
 
Control is the base class that things like TextBox and Button derive from.
 

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

Back
Top