Microsoft Office InfoPath 2003 Kick Start

 <  Day Day Up  >  

A form control is a graphical object that allows a user to interact with an InfoPath form so that they in some way affect the XML data that will be submitted from the form. Several InfoPath form controls are very similar to form controls in conventional HTML forms. For example, the InfoPath text box control corresponds closely to the text box produced by an HTML input element.

Some InfoPath form controls, such as a text box, have visual features and interactivity properties that are familiar to many developers and users because of the availability of identical or similar form controls in traditional HTML forms and Windows forms created using Visual Basic. Others, such as the repeating section control, will be unfamiliar to new users of InfoPath.

All form controls in an InfoPath form template are bound to the underlying data source of the form template. The binding of form controls is achieved in different ways, depending on how the form template was created. When a form template is created using the Data Source Setup Wizard, dragging parts of the data source to the form area can cause automatic association of the form control with a named field in the data source. When you create a blank form and insert a form control on the form area, you will likely want to rename the field in the data source from something like field1 to perhaps DateofBirth . If you don't want a data source to be created as you design a blank form, a check box on the Controls task pane turns off the automatic creation of a data source (it's turned on by default).

VISUAL ASPECTS OF INFOPATH FORMS

To make the topic of view design manageable, I have split the process into a detailed account of form controls (this chapter and Chapter 5, "Expression Boxes") and a description of layout tools in Chapter 6, "Designing Visual Aspects of InfoPath Forms." When you're producing InfoPath form templates, you must understand layout and know how to insert the appropriate form controls. If you prefer to look at layout first, turn to Chapter 6.

Selecting a Control from a Data Source

For the following section, we will use the very simple sample data source SampleSource.xml , shown in Listing 4.1. Notice that none of the elements in the XML file repeat. The XML file can be associated with an InfoPath form template by using the Data Source Setup Wizard but selecting an XML file as the data source.

To learn more about the Data Source Setup Wizard, see "Connecting Using the Data Source Setup Wizard," p. 11 (Chapter 1).

Listing 4.1. A Simple XML File Data Source

<SampleSource> <FirstName></FirstName> <LastName></LastName> <DateOfBirth></DateOfBirth> </SampleSource>

When you have a defined data source, you can simply drag a field in the data source to the form area. For many fields, the default form control will be the text box. If that is the control you want to use, that's fine; but you might want an alternative control ”for example, an option button control. If a text box control isn't what you want to use, right-click the relevant field in the data source (see Figure 4.1) and choose a different form control from the list offered in the drop-down menu before you drag the field to the form area.

Figure 4.1. Changing the form control associated with a data source field.

If the form control you want is not in the list offered when you right-click, you can click on More to open the Select a Control window (see Figure 4.2). It offers you a full list of form controls suitable for the applicable field.

Figure 4.2. The Select a Control window.

From the context menu of a form control, you can change the component of the data source to which the form control is bound. Or, using the Change To option on the context menu, you can change the form control to a preferred alternative.

 <  Day Day Up  >  

Категории