Pre-select items in a Multiple-Selection List Box in InfoPath 2010

Applies to: InfoPath 2010

Learn how to use default values to pre-select items in a multiple select list box in InfoPath 2010.

ADVERTISEMENTS

Problem

You have an InfoPath multiple-selection list box on a form and you would like to pre-select items, that is, have a few items in the list appear selected when the InfoPath form opens for the first time.

Solution

Add Default Values to the InfoPath multiple-selection list box, so that items are automatically selected when the InfoPath form is opened for the first time.

Discussion

You can pre-select items in a multiple select list box in InfoPath 2010 as follows:

  1. In InfoPath Designer 2010, create a new Blank Form template.
  2. On the Home tab in the Controls group, click Multiple-Selection List Box to add the control to the InfoPath form template.
  3. Follow steps 2 through 5 of the article to create an InfoPath XML data connection to an XML file in InfoPath 2010 to add a data connection to an XML file to the InfoPath form template.
  4. Click on the Multiple-Selection List Box to select it.
  5. On the Properties tab under the Properties group, click Control Properties.
  6. On the Multiple-Section List Box Properties dialog box under the List box choices, select the Get choices from an external data source radio button.
  7. The data source you created previously should be automatically selected in the Data source drop-down list box. If not, select it from the Data source drop-down list box.
  8. Click the button behind the Entries text box.
  9. On the Select a Field or Group dialog box, select a repeating group, and click OK.
  10. On the Multiple-Section List Box Properties dialog box, select appropriate fields for the Value and Display name, and then click OK.

In the example in this article, the list box will contain the names of running shoe brands such as Mizuno, ASICS, Brooks, Saucony, and New Balance.

To display a few items (for example, Mizuno and Saucony) pre-selected when the InfoPath form opens:

  1. On the Data tab under the Form Data group, click Default Values.
  2. On the Edit Default Values dialog box, expand group1.
  3. Click field1, and then type one of the values that you want to pre-select in the Default value text box. In our example, we'll type Mizuno.
  4. Right-click on field1, and then select Add another field1 below from the context menu that appears.
  5. Type the second value that you want to pre-select in the Default value text box. In our example, we'll type Saucony.

    Edit Default Values dialog box in InfoPath 2010

    Figure 1. Edit Default Values dialog box in InfoPath 2010.

  6. Continue adding as many field1 nodes as you require for pre-selecting values in the Multiple-Selection List Box. Click OK when you're done.

Press F5 to preview the InfoPath form. The items pertaining to the values that you entered as Default Values should now appear selected in the Multiple-Selection List Box when the forms opens.

Pre-selecting items in a Multiple-Selection List Box in InfoPath 2010

Figure 2. Pre-selecting items in a Multiple-Selection List Box in InfoPath 2010.

This solution also works with the 2 other list box choices, that is, Enter choices manually and Get choices from fields in this form. This solution is independent of the data source you choose to use, but it is recommended that any Default Values you specify exist in the data source that is bound to the InfoPath Multiple-Selection List Box.

 


Related InfoPath Articles:

 

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