View Object

Microsoft Office InfoPath

View Object


Represents a view within a Microsoft Office InfoPath 2003 form. 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.

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.

Using the View object

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:

    var objView;

objView = XDocument.View;

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


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:


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