473,569 Members | 2,593 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

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
2 2620
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
1879
by: smartnose | last post by:
say, when I have set the font and get a string like "hello world", how can I compute the exact space this string will take when I paint it on a form? Thank you.
2
2459
by: Benny Raymond | last post by:
Since I have no control over a treeview's scroll bars (i'm drawing icons and text to the right of the treenodes) I've decided to just add some special text to the end of my tree node text which I will then strip out when it comes to drawing the treenode into the treeview... Anyway I know there is a way to get the pixel length of a string...
9
7076
by: zion | last post by:
Hello, In my program I get data from table with 2 fields and enter it like in example into string array. How can I add the right spaces to the string? I use the function mystring.Tostring().PadLeft(10,' ') but the result is not good. 1234567890 | ABCDEFG
1
3096
by: dantz | last post by:
Hi everyone, I have a textbox which is multiline and wordwrap is true. I did not set any scrollbar because I want to show it manually (using different buttons) The textbox will sometimes have double byte strings (chinese characters) Question: 1) How can I know if I need to show the scrollbar base on the text inside the textbox? Options:
0
7700
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7924
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8125
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7974
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6284
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5219
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3653
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3642
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
938
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.