text wrap in a label

C

chad

Does anyone know how to do a text wrap in a label or checkbox control,
in CF?

If so what is the code? I have tried a few things like /r/n and
System.Environment.NewLine but i'm having ZERO luck can you help!!!!

Thanks!

Chad
 
S

shrenik

As far as I remember....if you increase the height of the label, i.e.
run it into multiple lines....the text should auto-wrap.

Now, to find out exactly how many lines you want the label height to
expand to.....you'll have to find out the length of the text in
pixels....CF1.0 has no support but CF2.0 has a public method
MeasureString(...) or something like that in the
System.Drawing.Graphics class which you can use to get the string
length in pixels. Divide this length by the wrap-length and you get the
number of lines the text 'would' wrap into....so simply set the label's
height to fit those many lines of text...voila!

For CF1.0, I remember, we had to maintain a static list of each
character with its pixel width...only to find out the length of an
entire text in pixels!!!
 

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