Resize a textbox to fit a user selected font/size

Nancy26

New member
Local time
Today, 09:24
Joined
Aug 3, 2001
Messages
9
Is there a way to change the height of a textbox on a form based on the fontsize selected from a combobox on the same form?

I want to do a preview of a font and font size right on my form, but I can't figure out how to get the textbox for my preview to be the right "size to fit" the selected font. The height of the textbox will need to change each time a font is selected.
 
Nancy-

This is an interesting problem. I think the font size is given in "points", which is an old typesetting term. A point is 1/72 of an inch. You might fool around with setting the height of the box to something like 0.1+CDbl(tbxFontSize)/72., where the 0.1 is to account for the top and bottom margin within the box.

Please let us know if this does the trick.

Thanks,
Jim
 
Thanks for the reply Jim. Your solution is very similar to another one I received earlier. (textbox.fontsize + 2) * 20
The 2 is for the top and bottom margin and the fontsize * 20 = twips.
It's always good to have more than one solution. Thanks again.

Nancy
 

Users who are viewing this thread

Back
Top Bottom