473,326 Members | 2,134 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.

Auto Newlines

Hi.
I was wondering if anyone knew how to obtain the average char width for the
default font used on labels. That or how to obtain the Graphics object for a
Bitmap object. I'm trying to write some code that would automatically add
newline codes (\n in C#) to a String so that it doesn't exceed a specific
width. While textboxes provide this functionality, labels don't, and I can't
use a textbox for what I'm currently doing because textboxes don't support
transperent beckgrounds.
If anyone could solve one of my problems, I'd be grateful.
Reuben.
Oct 11 '05 #1
1 1495
Reuben wrote:
I was wondering if anyone knew how to obtain the average char width for the
default font used on labels.
I don't think there's such a thing as an average width you can use to
calculate string width (for proportional fonts, that is), you should
measure the string instead using the Graphics.MeasureString method.
That or how to obtain the Graphics object for a
Bitmap object.
Graphics.FromImage
I'm trying to write some code that would automatically add
newline codes (\n in C#) to a String so that it doesn't exceed a specific
width. While textboxes provide this functionality, labels don't, and I
can't
use a textbox for what I'm currently doing because textboxes don't support
transperent beckgrounds.


When AutoSize is false, a Label will wrap its text content to the label's
width. I think it's always done that for me :-) Is there something wrong
with this?
Oliver Sturm
--
Expert programming and consulting services available
See http://www.sturmnet.org (try /blog as well)
Oct 11 '05 #2

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

Similar topics

4
by: Christopher Finke | last post by:
I have a site wherein the clients can update the individual pages by editing the text of that page in a <textarea>. Then, when the page is displayed, all of the newlines (\n) are converted to HTML...
4
by: Grant Edwards | last post by:
I'm using xml.sax to parse the "datebook" xml file generated by QTopiaDesktop. When I look at the xml file, some of the attribute strings have newlines in them (as they are supposed to). ...
6
by: dbee | last post by:
So I can't seem to urlencode a file with newlines ... it just gives me a series of T_STRING unexpected parse errors... cat job_description | while read file ; do php -r "echo...
1
by: dbee | last post by:
Hi, So I'm having a problem with disappearing newlines. I import the newlines from a file into my shell script fine. But then I process the text and the url_encode comes out the other end with...
0
by: skip | last post by:
*argh!* I hate XML! There, now that that's off my chest... I am trying to save Python code as attributes of an XML tag with xml.dom.minidom machinery. The code, predicatbly enough, contains...
2
by: Edward K. Ream | last post by:
Hello all, I recently ran across a situation in which sax.saxutils.quoteattr did not work as I expected. I am writing Leo outlines as opml files http://en.wikipedia.org/wiki/OPML which forces...
1
by: HopfZ | last post by:
Not a question. I tested how two kinds of newlines (\n and \r\n) interact with three browsers: Fx (Firefox 2), Op (Opera 9), Ie (IE 7) (all three on Windows XP). Result: The string...
5
by: lister | last post by:
Hi, I am trying to output a newline, but this doesn't work: echo "Line1\nLine2"; Before anyone says, I know HTML doesn't recognise newlines. I don't need newlines in the rendered HTML, I...
4
by: -Lost | last post by:
For example: var newlines = 'a\n\nb\n\nc'; alert(newlines); Yet, if I get that *exact* same line from an XMLHttpRequest's responseText, it is always alerted as: a\n\nb\n\nc
4
by: lihao0129 | last post by:
Hi, folks: I recently went through a strange problem with my Javascript code, say: I have a string variable which are from a 'textarea' element and I want to remove the trailing newlines inside...
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: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
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...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
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.