Quick Tip: Display button text on two lines in InfoPath

Filed under: InfoPath 2007

Learn how you can use a secondary data source to display text on two lines on a button in InfoPath thereby creating a multi-line button label in InfoPath.

ADVERTISEMENTS

Once in a while I go through the log files of my InfoPath website and sometimes I find some interesting things that InfoPath or SharePoint users want to do with Microsoft products.

Recently I found the following search query in my logs: button text infopath two lines.

While it is not always clear to me what a searcher is/was looking for, sometimes the queries are descriptive enough that I can get an idea of what a person is trying to do.

So I decided to have a bit of fun today and write a post about how you can place the text that goes on a button – more officially called a "label" – on two lines on the button in InfoPath. It’s kind of a workaround, but I hope you’ll find this solution useful.

To display button text on two lines in InfoPath and create a multi-line label:

  1. Create an XML file that has the following contents (with the line-breaks exactly as you see them here on the screen):

    <?xml version="1.0" encoding="UTF-8" ?>
    <label>Line 1
    Line 2
    </label>

  2. In InfoPath, create a Receive InfoPath data connection to an XML document, and specify the XML file you created in the previous step.
  3. Add a button to your InfoPath form template and use the formula button behind the Label field on the Button Properties dialog box to set the value of the button’s text to the label node of the secondary data source to the XML file.

    Selecting the label node in the secondary data source to the XML file containing the multi-line button text

    Figure 1. Selecting the label node in the secondary data source to the XML file containing the multi-line button text.

The resulting multi-line button label is shown in Figure 2 with the button text spanning two lines.

Multi-line button text in InfoPath

Figure 2. Multi-line button text in InfoPath.

This solution works for InfoPath forms that are filled out through the InfoPath client application and through a browser.

 


Related Posts

 

Copyright: This article may not be used on web sites (whether personal or otherwise), copied, disseminated, altered, printed, published, broadcasted, or reproduced in any way without an expressed written consent. The techniques demonstrated in this article may be used within any Microsoft InfoPath project. This article is provided without any warranties. Copyright for this article is non-transferrable and remains with the author.

InfoPath 2013 Cookbook: 121 Codeless Recipes for Beginners

InfoPath 2013 Cookbook 2: 121 Codeless Recipes for SharePoint 2013

InfoPath 2010 Cookbook: 101 Codeless Recipes for Beginners

InfoPath 2010 Cookbook 2: 101 Codeless Recipes for SharePoint 2010

InfoPath 2010 Cookbook 3: 101 Code Recipes for C# Developers

InfoPath 2010 Cookbook 4: 101 Code Recipes for VB Developers

InfoPath 2010 Cookbook 5: Integrating InfoPath with Excel and Excel Services