473,326 Members | 2,095 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Why TextBox width is different from that Graphics.MeasureString()

I did a test typing characters until fill out whole textbox (single line).

Then I chcked width of this string in paint event
e.Graphics.MeasureString(textBox1.Text,textBox1.Fo nt).Width

e.g. the textBox1.Width=268

I typed in 35 'A' with default Font. width retured from MeasureString
function is 252

It is quite different from textBox1.Width.

Note: I can see that the both sides of the typed string just touch left and
right sides of the textBox1 control.

Why the difference is so big? different units?

Thanks
Nov 16 '05 #1
0 2181

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Adam | last post by:
Can someone please help!! I am trying to figure out what a font is? Assume I am working with a fixed font say Courier 10 point font Question 1: What does this mean 10 point font Question 2:...
2
by: Tamir Khason | last post by:
I want to resize my textbox base on the text in it. Ways: 1) MeasureText - quite wrong 2) Detect VScroll - BUT HOW? 3)..... Please advice -- Tamir Khason
6
by: Mats-Lennart Hansson | last post by:
Hi, I want to calculate the actual text width. The word "init" is for example smaller than the word "wimp". Is there an easy way to do this? Thanks, Mats-Lennart
6
by: Scott Kilbourn | last post by:
Hi, I'm writing a control that inherits from TextBox. I need to adjust the width of this control based on the number of characters in the control. I'm having a hard time with this. The...
2
by: Udi | last post by:
Hi, I have a simple multiline TextBox which I need to set its width according to the longest line in Lines. I assume I need to calculate the font width, how do I do that? Thanks!
3
by: Dave | last post by:
Hey all, Ok, here's another of my fun questions. I want to rewrite the textbox control in VB.NET. I need to implement superscript and subscript within the box. Don't ask why, but I can't use...
4
by: Usmaak | last post by:
Hi, I have a TextBox that is set to a certain width. From this, I need to figure out the max number of characters that can fit into the TextBox. I'm using Courier New font, size 8.25. I've...
10
by: Per W. | last post by:
Is it possible to have dynamic size on a textbox? If the context is only one line then the box is only one line, but if the context is 10 lines then the box adjust to this? /Per W.
10
by: garyusenet | last post by:
I have a multiline textbox. The size of the text box should be 75 characters wide, and 5 lines in height like this: - <---75 characters--> <---75 characters--> <---75 characters--> <---75...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.