text wrap in a label

  • Thread starter Thread starter chad
  • Start date Start date
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
 
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!!!
 
Back
Top