PC Review Forums Newsgroups Microsoft DotNet Microsoft Dot NET Compact Framework text wrap in a label

Reply

text wrap in a label

 
Thread Tools Rate Thread
Old 08-03-2006, 07:40 AM   #1
chad
Guest
 
Posts: n/a
Default text wrap in a label


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

  Reply With Quote
Old 08-03-2006, 09:15 AM   #2
kjetila
Guest
 
Posts: n/a
Default Re: text wrap in a label

try \r\n
and set Multiline = true

  Reply With Quote
Old 08-03-2006, 05:58 PM   #3
chad
Guest
 
Posts: n/a
Default Re: text wrap in a label

I tried both in my CF project and neither worked, is there no way to do
this?

  Reply With Quote
Old 08-03-2006, 07:12 PM   #4
shrenik
Guest
 
Posts: n/a
Default Re: text wrap in a label

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!!!

  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off