InfoPath is an Office application that enables users to design and fill out rich, XML-based forms. When designing a form, you can start with a blank form or infer the form structure from an XML data file, an XML schema file, a database, or even a Web service.
Every form can be composed of one or more views. A view is what users see when they fill out the form. Each view consists of one or more controls that are data-bound to XML data nodes. A node is a field or group in the data source that represents an item of the XML data behind the form.
You can add features such as conditional formatting, spell checking, and auto-complete to forms using the form's designer, but more complex forms might require custom code to achieve the desired results. For example, you might write code behind a form to verify that an e-mail address is valid, to fetch a current stock quote from a Web service, or to restrict certain views to be available only to users with a particular role such as an administrator.
Before VSTO, code behind forms in InfoPath consisted solely of JScript and VBScript code developed with the Microsoft Script Editor. Although easy to use, the script languages lack some of the language features that make developing and maintaining larger, more complex customized forms easier, such as strong typing, IntelliSense, and access to the .NET framework.
This chapter discusses how to use VSTO to create InfoPath forms with managed code behind them. The chapter starts with a brief overview of what must be installed on your machine to develop managed code behind an InfoPath form with VSTO and shows how Visual Studio and InfoPath work together. Then the chapter covers the InfoPath security model, deployment model, and event-driven programming model. We consider the data events that you can handle in your code. We also consider the InfoPath form object model and how to handle form-related events.
Part One. An Introduction to VSTO
An Introduction to Office Programming
Introduction to Office Solutions
Part Two. Office Programming in .NET
Programming Excel
Working with Excel Events
Working with Excel Objects
Programming Word
Working with Word Events
Working with Word Objects
Programming Outlook
Working with Outlook Events
Working with Outlook Objects
Introduction to InfoPath
Part Three. Office Programming in VSTO
The VSTO Programming Model
Using Windows Forms in VSTO
Working with Actions Pane
Working with Smart Tags in VSTO
VSTO Data Programming
Server Data Scenarios
.NET Code Security
Deployment
Part Four. Advanced Office Programming
Working with XML in Excel
Working with XML in Word
Developing COM Add-Ins for Word and Excel
Creating Outlook Add-Ins with VSTO