Word Wrap / Alignment in Button Control? - InfoPath Dev
in

InfoPath Dev

Word Wrap / Alignment in Button Control?

Last post 03-23-2011 11:41 AM by dms.WebDev. 11 replies.
Page 1 of 1 (12 items)
Sort Posts: Previous Next
  • 04-17-2008 12:13 PM

    Word Wrap / Alignment in Button Control?

    Howdy:

    I'm new to InfoPath; trying to create my first form; I'm attempting to embed a button control; button needs to be labelled "Project Requirements Definition"; I can key that in the button control creation field, but when it displays, cannot see the whole label.  I do not see any way to format the button lable for text word-wrap and/or alignment.  How can I stack button label text to fit in a narrower space?

     

    Thanks!

  • 04-17-2008 03:45 PM In reply to

    Re: Word Wrap / Alignment in Button Control?

    Unfortunately, InfoPath uses <input type="button"/> rather than <button/>. This means that you have no way of wrapping text.

    You might try using a narrower font, like Arial Narrow.

  • 04-18-2008 06:43 AM In reply to

    Re: Word Wrap / Alignment in Button Control?

    Wow, I'm surprised.  So in all its glory, one will never see a button in an InfoPath form that has more than one row of text?

  • 04-18-2008 06:58 AM In reply to

    • Albert
    • Top 500 Contributor
    • Joined on 04-03-2008
    • The Netherlands
    • Posts 32

    Re: Word Wrap / Alignment in Button Control?

    If you really want a button with multiple lines, do the following:

    Create a new xmlfile with (kudos to the guy who though of this)

    <?xml version="1.0" encoding="UTF-8"?>
    <characters
        cr="&#xD;"
        lf="&#xA;"
        crlf="&#xD;&#xA;"
    />

    and add it as a secondary datasource.

    Set the label of the button to something like: concat("hi", xdXDocument:GetDOM("characters")/characters/@crlf, "there");

    Don't be suprised if the button doesn't have a linefeed in designmode. It will show when you fill in the form.

     

    Albert

  • 04-18-2008 07:13 AM In reply to

    Re: Word Wrap / Alignment in Button Control?

    Nice Albert.

    Thanks for the post.

    Another trick is create an image with the text and then use that trick but Albert's is better.

  • 04-18-2008 07:47 AM In reply to

    Re: Word Wrap / Alignment in Button Control?

    Greg / Albert / Clay:

    Thank you so much.  This forum is pretty amazing due to your kind of expertise.  It is helping me ramp very quickly.  Very much appreciated.

    Chris

  • 04-21-2008 04:04 PM In reply to

    Re: Word Wrap / Alignment in Button Control?

    Thanks Albert. I should note that this will only work in InfoPath 2007 as InfoPath 2003 does not support dynamic button labels. Well, not entirely true. The InfoPath 2003 DESIGNER does not support them. But if you design in InfoPath 2007, the InfoPath 2003 edit will display them.

  • 04-23-2008 02:03 PM In reply to

    Re: Word Wrap / Alignment in Button Control?

    Albert: I am still working on getting my InfoPath 2007 buttons to show more than one line of text. I have done the following:

    1. created a file named buttonstyle.xml that contains the following:

    <?xml version="1.0" encoding="UTF-8"?>
    <characters
        cr="&#xD;"
        lf="&#xA;"
        crlf="&#xD;&#xA;"
    />

     2. I've added this file as a secondary data source within my InfoPath file

     3. I've embedded a button control and keyed in the formula you indicated:

     concat("hi", xdXDocument:GetDOM("characters")/characters/@crlf, "there")

    All I get is a button with the formula text.  I suspect I am not putting in the correct second argument in the formula.  Does it need to reference the xml filename?  Also, do I need to publish the form before I can see the results?

     Thanks!  Chriis

  • 04-24-2008 04:19 PM In reply to

    Re: Word Wrap / Alignment in Button Control?

    You can't just type in the formula into the label text box, otherwise it WILL interpret it as plain text. You need to click on the formula button (labeled "fx") to the right of that text box and add the formula there. Then it will interpret it as a concat() function.

  • 04-24-2008 11:37 PM In reply to

    • Albert
    • Top 500 Contributor
    • Joined on 04-03-2008
    • The Netherlands
    • Posts 32

    Re: Word Wrap / Alignment in Button Control?

    And also change characters (the bold one: concat("hi", xdXDocument:GetDOM("characters")/characters/@crlf, "there")) into the name of your secondary datasource, most likely buttonstyle.

    If you have more knowledge of what you doing you might be able to solve more problems, so here we go:

    The text on the button is constructed with data from a secondary datasource, in this case probably buttonstyle.xml.

    Concat is an xpath function that joins strings ( = text) into one string, for example: concat("a", "bc", "d") will result in "abcd". Because InfoPath won't let you enter a carriage return (cr) or linefeed (lf), someone constructed this xml file. The 'weird characters' are a 'special' representation of a carriage return and linefeed, InfoPath will display them as cr/lf. If you just add &#xD; on the label it will display it as text, not the 'special' representation. So what happens here is: combine the text hi with crlf from the secondary datasource 'buttonstyle' and there, resulting in a button with two lines of text.

    Goodluck,

    Albert

     

  • 04-25-2008 11:27 AM In reply to

    Re: Word Wrap / Alignment in Button Control?

    Albert:
    Outstanding; I'm an MS Excel hack, so I'm familiar with concatenate function; thanks for connecting it to XML which I do not know.  I have been reading up on InfoPath and learning about data sources, so I can follow that, too.  I will be trying your last suggestions soon.  Best Regards.  Chris

  • 03-23-2011 11:41 AM In reply to

    Re: Word Wrap / Alignment in Button Control?

    I know this is an old post but this worked like a charm.  Albert special thanks to you for explaining what the function does - this was extremely helpful.  At first this appeared to not work - I had to view it in preview to see the line break.  Thanks again!

Page 1 of 1 (12 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.