The preceding three chapters of Part II in this book, Designing InfoPath Forms, concentrate on the technicalities of creating, laying out, and adding sections and controls of various types to forms. This chapter takes a different tack; it deals primarily with form presentation issues, such as the use of graphics and colors to embellish your form designs, and using conditional formatting to alter the appearance of text box controls. Working through this chapters exercises wont turn you into a full-fledged graphic artist, but youll learn some techniques to give your forms a more professional appearance and, hopefully, make them easier on users eyes. Youll also learn how to minimize data entry errors using conditional formatting. Conditional formatting lets you change the appearance of, hide, or disable controls in response to field value changes.
The black and white screen captures in this book will make it difficult for you to see the effect of altering colors. Youll find that performing the exercises in this chapter will be much more illustrative .
The section Adhering to Design Standards in Chapter 5, Laying Out Forms describes the benefits of establishing a uniform approach for designing master layout tables and their embedded contents. Most example forms in Chapter 5 and successive chapters use a standard, two-row master table in which the form title appears in the first row and all other form components appear in the second row. This base design lets you add a standard background color to the master table for all forms you create.
The figures in this book and the examples in this chapter use the standard Microsoft Windows XP theme. If your organization has adopted a custom Windows XP color scheme or theme, youll undoubtedly want to adopt background, control, and, possibly, border colors for tables, controls, or both that complement the scheme. Bear in mind that youre not designing a Web page or advertising your organization wares or services with InfoPath forms. The best policy for adding color and graphic images to forms is conservatism regardless of your political persuasion.
InfoPath comes with 17 predefined color combinations, which you select in design mode from the Color Schemes task list, as shown in Figure 7-1. Each combination has six color squares, but most schemes have duplicate colors in positions 4 and 6 (numbered from left to right). You apply a color scheme to your form s master layout table by clicking the name of the scheme in the Color Schemes task pane. Layout tables, repeating tables, and sections are transparent by default, so they receive the color scheme s background color if you haven t previously applied shading to a table or section. (The 25 sample InfoPath forms use the Blue color scheme, but they don t embed sections and repeating tables in a master layout table.)
Figure 7-1: The Color Schemes task list lets you select one of 17 predefined sets of colors for form, table, and control backgrounds and text.
Here s how InfoPath applies the colors of the scheme you select to a form s master layout table:
This chapter s exercises use the NWOrderCh6.xsn template in your C:Microsoft PressIntroducing InfoPath 2003Chapter07NWOrdersCh6 folder. This template is a copy of the NWOrdersFinal.xsn example form from Chapter 6.
The Bright Blue color scheme is well suited to Windows XP s default theme. The position 1 color almost matches the title bar color in the InfoPath window, and the position 3 color is similar to the toolbar background. To add the Bright Blue color scheme to the NWOrdersCh6.xsn template, follow the steps on the next page.
Apply a color scheme
If you want to remove the color scheme and revert to the original design, click None in the Apply A Color Scheme list.
To establish a uniform brightness level within the form s window, which users might find easier on their eyes, you can surround the master table with a background color. You add a background color by choosing Format, Background Color to display the View Properties dialog box. The default Background Color selection is Automatic, which translates to no applied color (the window s background color). Opening the list displays a color picker control. After you apply a color scheme to a form, the scheme s six colors appear as selections in square buttons at the top of the color picker, as shown in Figure 7-2. (Before you apply a color scheme, these buttons aren t present.)
Figure 7-2: This template has the color of position 4 ( primaryLight ) applied as the view s background color.
To add a background color to the NWBrightBlue.xsn template, follow these steps.
Apply a background color
SP-1 To remove a background color, open the View Properties dialog box and choose Automatic in the Background Color list box. As an alternative to a background color, you can add a picture (a bitmap image) to serve as the form s background.
The section Picture Controls in Chapter 6 explains how to add picture controls whose binary data is embedded in Picture ( base64Binary ) fields of the forms XML data document. You also can embed logos or other static graphics in templates. If youve worked with Microsoft Access forms, an InfoPath embedded picture corresponds to an Access image control with an embedded bitmap, such as that of the Switchboard form in the Northwind sample database. You can insert a picture from a file or from a clip art image. For clip art images, use the process described in the Chapter 2 section Inserting Pictures into Rich Text Boxes.
The examples in this section use the Northwind Traders logo captured as a Graphics Interchange Format (GIF) file from the Switchboard form and modified to change the background color from dark gray to the primaryLight background color. You dont need to change the background color of transparent GIF files. Adding an image to a form adds a FileName.ext copy of the original graphics file to the .xsn file, where FileName is eight random hexadecimal characters (0 to 8 and A to F), and ext is the source files extension. You might see a thumbs.db database file in the templates folder after you add a logo or other image. This file holds thumbnail images for graphics files in the folder; it isnt required, and you can safely erase it.
Adding the logo to a vacant or added table cell makes it easier to control the spacing between a logo or graphic and its surrounding text, as well as the alignment of the image. To add, resize, and pad a logo included with the sample files for this chapter, follow these steps.
Insert a logo from a file
Resize and reposition the logo
A lot of empty space lies to the right of the logo you added in the preceding section, so a natural inclination is to fill the hole with a slogan , organization propaganda, or user instructions. Giving in to this temptation lets you try adding InfoPath s preformatted headings to a table cell .
The Pick Formatting To Apply list in the Font task pane has HTML heading styles 1 through 5, Normal (10-point Verdana is the default), and Clear Formatting choices. Applying a color scheme assigns the primaryVeryDark color to headings. The larger headings enable you to add outlandishly formatted text, as shown in Figure 7-3. ( Before has the orange accentDark color applied.)
Figure 7-3: This is an example of overdoing the addition of headings and applying a garish font color to a form with the Bright Blue color scheme.
To add and format headings in the cell to the right of the logo that you added to the NWBrightBlue.xsn template, follow these steps:
Add, center, and format headings
If you want to remove the formatting, select the text and click the Clear Formatting item in the Pick Formatting To Apply list.
You also can apply the color scheme to the labels on your form, although doing this might reduce their contrast if you haven t applied a bold attribute. The three bold form section headings are good candidates for the primaryVeryDark color.
Hyperlinks (HTML anchors) that you embed in forms aren t InfoPath controls because they don t bind to an XML Data document field. In this respect, hyperlinks are similar to embedded images. You can place a text-based (label) hyperlink at any location in the form or add a hyperlink to a graphic. To give both techniques a try with links to Microsoft sample Web pages for hyperlinks in the Northwind sample database s Suppliers table, follow these steps.
Add a hyperlink to a table cell
Add a hyperlink to an embedded image
Figure 7-4 shows the result of adding the text and image hyperlinks to the form. You can t change the style or color of the border that the hyperlink adds to an image in InfoPath s user interface. You can remove the border by selecting the logo, choosing Tools, Borders and Shading, and clicking the None button on the Borders tab. Your C:Microsoft PressIntroducing InfoPath 2003Chapter07NWBrightBlue folder contains NWBrightBlueLogo.xsn, which includes all modifications you made in the preceding exercises.
Figure 7-4: This preview of the NWBrightBlue.xsn template shows the added text and image hyperlinks.
The Chapter 5 section Adding Table Borders briefly describes the process for adding outside and inside borders to layout tables and applying padding to cell contents. The sections that follow explain the formatting process in greater detail and describe how to add colors from a selected color scheme to individual tables and controls and their borders. Like the preceding examples, these exercises start with a copy of the NWOrdersCh6.xsn template but use a different color schemeBlueberry.
Its often useful to distinguish individual layout tables from one another, such as Customer Information from Order Information, or relate specific table elements to one another using background colors. For this example, you assign one background color to the Customer Information table and the Shipping Information rows of the Orders table, and another background color to all other Order Information elements, including the Line Items repeating table header. Adding outside and inside borders to tables is optional, but borders make the Customer, Order, and Shipping Information sections consistent with the default design of the Line Items repeating table. Adding a small left margin to the labels by cell padding improves the overall appearance of the form.
To change the background colors of the NWBlueberry.xsn template, apply table borders, and add left cell padding with InfoPaths multiselect feature for table cells, follow these steps.
Create a copy of the source template and change table background colors
Add table and row borders
Pad all label cells at once with column multiselection
The default borders for text boxes often appear to vanish when you add table background colors. You can make the borders reappear by applying a darker color to them. The following steps also show you how to use InfoPaths multiselect feature for controls.
Add visible borders to all applicable controls at once
A drawback to adding darker borders to controls is that the blue border surrounding an empty control with the focus is difficult to discern from unselected controls, although the presence of the cursor in the selected text box mitigates the problem. You probably wont notice this potential issue with forms that have default values.
Conditional formatting is one of the most important features you can use in InfoPath to alert users of out-of-range, undesirable, or suspect values when they re entering data. Conditional formatting doesn t flag those values as errors; usually, it provides users a visual clue that the data is or might be incorrect. Chapter 8 describes declarative data validation rules that define erroneous entries. You apply conditional formatting primarily to text boxes; conditional formatting is disabled for date pickers, both list box types, check boxes, and option groups. Conditional formatting can apply any or all font attributes, change the font and background colors, or hide or disable the control.
These are some typical applications for conditional formatting alerts:
To apply conditional formatting to a control, choose Format, Conditional Formatting to open the Conditional Formatting dialog box, which initially displays an empty Conditions With Formatting list. Alternatively, open the control s Properties dialog box, click the Display tab, and click the Conditional Formatting button to open the dialog box. Click Add to open the Conditional Format dialog box, and specify the field name , a comparison expression, and a constant or field value in the three text boxes, as illustrated in Figure 7-5. The two open lists hide the Font Color (bright orange) and Background Color (dark blue) selections in the figure; although this figure shows both lists open, only one list can open at a time.
Figure 7-5: This image shows selections available in the comparison expression and compare-to values of the Conditional Format dialog box.
As an example of conditional formatting, the NWBlueberry.xsn template s default ShipAddress and PostalCode field values aren t the same as the Address and PostalCode field values. When you open a preview of the form, the expression shown in Figure 7-5 applies the conditional formatting to the text box bound to the ShipAddress field, as shown in Figure 7-6.
Figure 7-6: Grab the data entry operator s attention with orange and blue conditional formatting applied to the Shipping Information Address text box that s bound to the ShipAddress field.
The most common type of programming logic is positive; if the condition is satisfied, the expression evaluates as true . Multiple expressions can use and logic to draw a final conclusion ”if Expression1 is true and Expression2 is true, and so on, the final result evaluates as true . An alternative is or logic ” if Expression1 is true or Expression2 is true, the final result evaluates as true . InfoPath conditional expressions also provide a not version for most conditions, so you can specify a condition that evaluates as false .
As an and logic example, you might not want to highlight empty Shipping Information text boxes when adding a new order for a customer. In this case, you add another condition with and logic ” ShipAddress is not blank ” as shown in Figure 7-7.
Figure 7-7: A second expression that uses the not operator demonstrates multiple conditional formatting criteria.
If you need another condition, such as testing whether an asterisk (*) in a shipping address field represents same as customer s corresponding billing address field, add another and condition ” ShipAddress is not * .
In the Conditional Formatting dialog box, you can add multiple sets of conditions, which is the equivalent of adding parentheses around multiple logical expressions to cause them to be evaluated as a group . Multiple condition sets are limited to the or operator ”if any condition group evaluates as true, conditional formatting is applied to the control. The following sections show you how to establish single and multiple condition sets.
The preceding section defined potential criteria for acceptable values of the text box bound to the ShipAddress field. In this exercise, you add those criteria and extend their application to text boxes bound to the ShipCity, ShipRegion, ShipPostalCode, and ShipCountry fields. Instead of an asterisk, the ShipAddress text box accepts Same as Bill To Address (*) as an acceptable entry, in preparation for exercises in later sections.
To set up conditional formatting for the NWBlueberry form s Shipping Information section, follow these steps.
Add the initial criterion
Add the second and third criteria and test the result
Add the remaining four * criterion fields
Add the Same as Bill To Address (*) criterion
SP-1 Optional ShipVia and Freight field values are required if the order has been shipped, which is indicated by a non-blank value in the nillable ShippedDate field. You can apply conditional formatting to the ShipVia text box, the associated drop-down list box, or both. The example in this section formats the text box. Testing the Freight field value requires two expression groups that use the Or operator to disallow a blank value or a value less than $5.00. Northwind Traders minimum shipping and handling charge is assumed to be $5.00.
To add conditional formatting to the ShipVia and Freight fields, follow these steps.
Add criteria to the Ship Via text box
Add criteria groups to the Freight text box
Figure 7-8: This preview of the NWBlueberry.xsn template shows conditional formatting applied to Ship Via, Freight, and Shipping Information fields.
One of the most useful features of conditional formatting is its capability to hide controls that don t require values under a specified condition. For example, all but a few of Northwind Traders orders have the same billing and shipping addresses. In this case, it makes sense to default shipping addresses to billing addresses when an element or attribute value specifies the same address. One approach is to use the Insert Formula dialog box to add default Shipping Address values from the Customer table s address field values, as described in the section Adding Workflow-Dependent Rules in Chapter 10, Adding Views to a Template.
Alternatively, you can establish generic default values for a shipping address that s identical to the billing address. You prepared for this eventuality with the conditional formatting expressions in the preceding section ”Same as Bill To Address (*) for Company and * for all other Shipping Information fields are valid entries. Valid entries are required in hidden controls that the schema specifies as requiring at least one character ( minLength="1" ). The XML Schema specification calls minLength a constraining facet .
The next exercise adds a check box with a default true value bound to a Boolean attribute value specifies that the Shipping Information controls are hidden by default. The check box s value is metadata, so an attribute ”rather than an element ”is the appropriate field type.
Hiding controls also demonstrates the use of multiple conditional formatting expressions for a control. To add a bound check box to a new True/False (boolean) field and apply an additional conditional formatting expression group to control visibility of the Shipping Information controls, follow these steps.
Add a new True/False field and change default values
Selectively hide Shipping Information controls
Figure 7-9: This test form created from the final version of the NWBlueberry.xsn template has two text boxes that contain inappropriate values.
The final version of the NWBlueberry.xsn form that incorporates the conditional formatting expressions added to this point is in your C:Microsoft PressIntroducing InfoPath 2003Chapter07NWOrdersFinal folder.
The conditional formatting exercises you worked through in the preceding few sections only scratch the surface of what you can accomplish with conditional formatting. The next chapter, which covers data validation, uses similar expressions for validating text data.
SP-1 The Format Painter toolbar button lets you copy the formatting of a control or text and apply it to other controls or text on the form. InfoPath s Format Painter feature is similar to that of all Office 2002 or later applications, such as Access. You select the control or text with the format you want to copy, click or double-click the Format Painter button, and then click the text or control to apply the formatting. Double-clicking the Format Painter button locks the button in the enabled state to let you apply formatting to multiple text or control instances. You click the button again to disable the locked button. Unlike the Format Painter in Access, the InfoPath version doesn t apply the source control s conditional formatting rules to the target control.
To give the Format Painter a test, follow these steps.
Apply a label format to other labels and controls
The Format Painter is especially handy if you decide to change the formatting of many text items, controls, or both in a form.
InfoPaths panoply of custom formatting features make it easy to design attractive forms. You can apply one of InfoPaths 17 color schemes to the title and second row of a master table, and then use any of the schemes lighter colors to apply a background color to the entire form, individual embedded layout tables, individual table cells , or controls. You also can use the selected schemes colors for table and control borders.
You can embed images from graphics files or clip art in pictures that InfoPath saves as part of the form template. You also can apply unbound hyperlinks to embedded images or descriptive text for the link. Views contain the data for embedded hyperlinks . InfoPath has a set of five predefined HTML headings that range in font size from 24 to 8 points.
You minimize the probability of data entry errors or omissions by taking advantage of InfoPaths declarative conditional formatting of text box controls. The Conditional Format dialog box makes it easy to generate simple or complex logical expressions that alter the appearance of or hide individual controls. If you cant create a single expression to implement the conditional formatting rules you need, the Conditional Formatting dialog box lets you add additional sets of rules, which are evaluated by a built-in Or operator.
1. |
Can I create my own custom color schemes? |
|
2. |
How do I embed a clip art picture in a form? |
|
3. |
Can I apply conditional formatting to values in repeating table rows? |
|
4. |
Can I use different conditional formatting colors to indicate the severity of a data entry problem? |
Answers
1. |
No. InfoPath color schemes are hard-coded. However, you can create your own set of custom colors by clicking the More Colors item in a color picker to open the Color dialog box, and typing decimal values (0 to 255) in the Red, Green, and Blue text boxes. InfoPath doesn t save custom colors between sessions; a session ends when you close InfoPath. |
2. |
Choose Insert, Picture, From Clip Art to open the Clip Art task pane, and follow the same procedure as you did when inserting a clip art picture in a rich text box. (See the Chapter 2 exercise, Inserting an Image from the Clip Art Task Pane. ) |
3. |
You bet. The next chapter shows you how with data validation and conditional formatting examples. |
4. |
Yes. Add multiple conditional formatting expression groups with different settings for the Font Color and Shading properties. |
Here are additional exercises to test your understanding of conditional formatting expressions:
Part I - Introducing Microsoft Office InfoPath 2003 SP-1
Part II - Designing InfoPath Forms
Part III - Working with Databases and Web Services
Part IV - Programming InfoPath Forms