Points, Pixels and string lengths

A

Anne

I am creating text box controls "on the fly" for strings
of varying lengths. I want to make the text box size
match the size of the string. How do I convert the length
of the string (len) to pixels, which is required by Size.
The Font is sized in Point.

aTextBox.Size = new System.Drawing.Size((len * ??? ), 20);
 
M

Morten Wennevik

You can get the size of a string drawn with a given font with
Graphics.MeasureString();
 

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