By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,783 Members | 1,347 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,783 IT Pros & Developers. It's quick & easy.

MeasureString(string s,Font font) dosen't return right pixels

P: n/a
The function return quite rough pixels.

e.g. if you use Font: Verdana, Font style:Regular, Size:8 and type 60 upper
case
character C, the functuion returns pixels 478.3639, but actualy it occupies
a textbox
that has width 545 pixels, that is about 13% difference. When using the
function to
get pixels and grow a textBox, the textBox is not big enough to show all
characters.

For other characters like lower case i, it return more pixels than it it has.

So it is impossile to use the function to get pixels to expand or shink a
textbox
dynamically when typing character.

Is there any other way?

Thanks

May 15 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
The measure string method only returns the size of the string when
using the drawString method... Since a textbox has a border etc, the
size of the text box will be larger than just the size of the string.

Have you tried using the AutoSize property of the text box?

-Ben Childs

May 16 '06 #2

P: n/a
I did (AutoSize=true by default and it affects Height of a textBox only)

"bc***********@gmail.com" wrote:
The measure string method only returns the size of the string when
using the drawString method... Since a textbox has a border etc, the
size of the text box will be larger than just the size of the string.

Have you tried using the AutoSize property of the text box?

-Ben Childs

May 16 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.