Word Wrap in CheckBox Text?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • bjwest
    New Member
    • Dec 2008
    • 12

    Word Wrap in CheckBox Text?

    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
    Recognized Expert New Member
    • Mar 2008
    • 221

    #2
    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.

    Comment

    • bjwest
      New Member
      • Dec 2008
      • 12

      #3
      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...

      Comment

      • SaiLove
        New Member
        • Jan 2009
        • 1

        #4
        I think We creat a string str = "line1 \n line2 \n line3 ...";
        Then checkbox.text = str;

        Comment

        • bjwest
          New Member
          • Dec 2008
          • 12

          #5
          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

          Comment

          Working...