Creating a Multi-Select List Box in InfoPath SP1 Preview
Creating a Multi-Select List Box in InfoPath SP1 Preview
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />
While InfoPath does not include a multi-select list box control, it is possible to create one using the controls present in InfoPath SP1 Preview:
<?xml:namespace prefix = v ns = "urn:schemas-microsoft-com:vml" />
Like all form design decisions in InfoPath, the first thing you need to do is think about the data you want to collect – how do you want the multiple selections represented in the XML saved or submitted by the InfoPath form? Additionally, do you want the selections to be determined at form design time (static), or at runtime (dynamic)?
Here’s one approach that allows either a static or dynamic list of choices by including the choices – and the selection state – right in the form data.
First, create a data structure as follows:
Here are the steps to do this:
- Go to the Data Source task pane
- Click the Add button, and add a node named “options” of type Group
- Add a node under options named “option” of type Group and check Repeating
- Add a node under option named “selected” with data type True/False (boolean)
- Add another node under option named “text” (with the default properties)
Note that if you want a very different data structure the rest of these instructions won’t apply directly, but they should get you started down the right path in terms of understanding how to create a complex control out of the primitives that InfoPath provides.
Now you need to build the view – here’s what I came up with, showing the design-time structure:
This is a Scrolling Region as the outer container for the control, containing a Repeating Table for the options, with a Check Box and Expression Box for each option. Here’s how you make it:
- Go to the Controls task pane
- Insert a Scrolling Region control, and resize it to the size you want the Multi-Select List Box control to be.
- Go to the Data Source task pane
- Drag the option group from the task pane into the Scrolling Region control; when the popup menu appears, select Repeating Table
- Double-click the Repeating Table indicator to show its properties
- On the Data tab, uncheck Allow users to insert and delete rows
- On the Display tab, uncheck Include header, then click OK
- Inside the Repeating Table, delete the text next to the check box in the first cell (which should say “Selected”), and resize the table cell so that the checkbox just fits within it
- Right-click the Text Box in the second cell, point at Change To and select Expression Box on the fly-out menu
Next, tweak the layout and borders to make it look professional:
- Double-click the Scrolling Region indicator
- On the Size tab, set the Top, Bottom, Left and Right Padding to 0 px, then click OK
- Select Format | Borders and Shading..., click Outline, then click OK
- Select the Repeating Table indicator, then go to Format | Borders and Shading... , select None, and click OK
- Click inside the Scrolling Region – although you can’t see them, there will be several empty paragraphs. Arrow down until the blinking insertion point is in the last paragraph, then hit Backspace to erase them. (If you forget to do this you may see blank lines after the options when you preview the form.)
Finally, if you want to make the selected options stand out clearly, you can use Conditional Formatting:
- Click the Repeating Table indicator, then go to Format | Conditional Formatting... and click Add...
- In the third drop-down, select TRUE (so the condition reads “selected” “is equal” “TRUE”)
- Click the Shading drop-down, and select a background color (e.g. light gray)
At this point, the Multi-Select List Box control is ready to go – but it doesn’t have any options! Maybe those options are specified by your form’s back end data source (a database or web service). But for now, let’s assume the list is static:
- Go to Tools | Default Values
- Right-click on the option node, and select Add another option below; repeat this to create as many options as you need.
- Expand each option, select the text node, and type the option name in the Default value text box at the bottom of the dialog. (To make an option selected by default, select the selected node and then select TRUE in the Default value drop-down.)
That’s it! Now just hit the Preview button on the toolbar to try our your new Multi-Select List Box control.
Note: You can also create ActiveX controls that do XML data binding with the InfoPath SP1 Preview.
Comments
Anonymous
April 01, 2004
can infopath be a real workflow ,if dose not get help from others such as sharepoint...
i mean dose the infopath can control work flow process and authoricenAnonymous
May 11, 2004
This is a commentAnonymous
July 30, 2004
ghmjdjAnonymous
August 17, 2007
The comment has been removedAnonymous
September 08, 2007
The comment has been removedAnonymous
September 08, 2007
The comment has been removedAnonymous
January 21, 2009
PingBack from http://www.keyongtech.com/1238956-how-can-you-set-upAnonymous
March 06, 2009
Hi Team: We are having Info Path Form 2007, But i am not able to find the contol "Scrolling Region" either in the controls or going through Insert > More Controls. Regards, Mukesh GiriAnonymous
March 06, 2009
Hi Mukesh, If the compatibility for your XSN is set to both InfoPath and Forms Services, then the Scrolling Region control is not available. When set to Forms Services, there are a number of controls that are not available: http://office.microsoft.com/en-us/infopath/HA102040851033.aspx ScottAnonymous
June 16, 2009
The comment has been removedAnonymous
June 30, 2009
Hi There, I'm having the same problem as Legun. I am using infopath 2003 and have created the multi-select as shown above (my selections are static). Now, I need to submit the form to a form library in sharepoint, but I cannot get the selected values to appear in a column within the library. This is very important as I need to filter on this column once it's in sharepoint. I've tried everything and can't get it working...I'm afraid my company will soon give up on infopath and go back to excel for creating forms....! Does anyone have any ideas?Anonymous
June 30, 2009
I forgot to ask... Is there anyway to make this multi-select show static values AND allow users to add a value. The multi-select in 2007 appears to offer this feature. ThanksAnonymous
May 10, 2010
Is there a way to load the control from a xml resource file? Any info you can provide will be helpful. ThanksAnonymous
August 08, 2010
does this work for browser enabled forms?Anonymous
January 04, 2011
Hi, Nice Blog, But I have 1 problem. How can we know that which check boxes are selected on submitting of form?