This documentation is archived and is not being maintained.

View Object

Office 2007
Represents a view within a Microsoft Office InfoPath 2007 form.

Version Information
 Version Added:  InfoPath 2003

Remarks

The View object provides a number of properties and methods that can be used to programmatically interact with an InfoPath view, including methods for selecting data contained in the view, switching from one view to another, synchronizing the view with a form's underlying XML document, and executing an InfoPath editing action.

InfoPath forms can contain one or more views, and one view is always defined as the default view. When you work with a view using the View object, you are accessing the currently active view.

Bb229875.vs_note(en-us,office.12).gif  Note
The InfoPath object model also provides the ViewInfos collection, which can be used to get information about all of the views implemented in a form.

For more information about using the View object, see Working with views.

Example

The View object is accessed through the View property of the XDocument object. For example, the following code sets a reference to a form's currently active view:

JScript
var objView;

objView = XDocument.View;

To change the currently active view, you can use the SwitchView method of the View object as follows:

JScript
XDocument.View.SwitchView("View2");

To force an update of a view based on changes in a form's underlying XML document, you can use the ForceUpdate method of the View object, as shown here:

JScript
XDocument.View.ForceUpdate();



Show: