Auto Newlines

G

Guest

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.
 
O

Oliver Sturm

Reuben said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top