Dennis,
You could always take the text that you want to place in the textbox and
pass it to the MeasureString method on the Graphics class. You would get
the Graphics instance for the textbox by calling the static FromHwnd method
on the Graphics class, passing the handle from the TextBox. Then, you would
pass the text and the font. The only thing you would have to do is handle
the border, but in the case of the TextBox, you might be able to use the
ClientRectangle property to get that information.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
-
mv*@spam.guard.caspershouse.com
"Dennis C. Drumm" <an*********@community.nospam> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
How can I determine if a string will fit in the display area of a text
box?
I don't want to use a char count because the width of each char can vary.
I suspect I need to convert the string to a graphic using the text box's
font, but I'm not sure how that would be done.
Thanks,
Dennis