Connecting Tech Pros Worldwide Help | Site Map

Word Wrap in CheckBox Text?

Newbie
 
Join Date: Dec 2008
Posts: 12
#1: Dec 18 '08
I know it's possible to wordwrap in a TextBox, but is it possible to do so in a CheckBox? This is a Win Mobile device, and the screen width is quite limited. I need the text wrapped, if longer than the width of the box, rather than truncated.

Is this possible, or am I going to have to create a custom object for this?
nukefusion's Avatar
Expert
 
Join Date: Mar 2008
Location: Essex, UK
Posts: 197
#2: Dec 18 '08

re: Word Wrap in CheckBox Text?


I don't know if it works the same for the compact framework but in standard winforms if you set the AutoSize property of the checkbox to False and reduce the width of the checkbox the text will wrap vertically in a similar fashion to the label.

Of course if you do that then it won't automatically resize to fit your text if you should change it, so you'd have to be careful or clever if you're implementing localization or if the text is dynamic in some way.
Newbie
 
Join Date: Dec 2008
Posts: 12
#3: Dec 18 '08

re: Word Wrap in CheckBox Text?


Thanks nukefusion. I looked all through the compact frameworks CheckBox object and couldn't find anything that would do any kind of autosizeing. The CF is way limited, compared to the standard toolset. I understand they have to save space on the mobile devices, but you'd figure with smart phones being able to switch between portrait and landscape, they'd see the need for this ability. I guess I'm going to have to create a custom object.

The best I can figure is to create an object that contains a CheckBox with no label and a TextBox for the lable. If I set the TextBox to multi line with wordwrap, I can resize it as needed.

Off to the drawing board...
Newbie
 
Join Date: Jan 2009
Posts: 1
#4: Jan 2 '09

re: Word Wrap in CheckBox Text?


I think We creat a string str = "line1 \n line2 \n line3 ...";
Then checkbox.text = str;
Newbie
 
Join Date: Dec 2008
Posts: 12
#5: Jan 2 '09

re: Word Wrap in CheckBox Text?


SaiLove, the CF checkbox does not have a multiline attribute. Anything after a newline is ignored and doesn't show in the textfield.

I got around this by creating my own custom control mentioned above. Right now, I'm trying to figure out how to resize the control when the vertical scrollbar is visible to prevent the horizontal scrollbar from being displayed.

This is a personal project I'm working that I've had to put on hold while developing a database app for the local Veterans Office
Reply


Similar Mobile Development bytes