# View Object

View

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.

## Remarks

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:

    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:

    XDocument.View.ForceUpdate();

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

©2003-2004 Microsoft Corporation. All rights reserved. Permission to copy, display and distribute this document is available at: http://msdn.microsoft.com/library/en-us/odcXMLRef/html/odcXMLRefLegalNotice.asp