Export (0) Print
Expand All

View Class (Microsoft.Office.InfoPath)

Represents a view within a form.

Namespace: Microsoft.Office.InfoPath
Assembly: Microsoft.Office.InfoPath (in microsoft.office.infopath.dll)

'Declaration
Public MustInherit Class View
'Usage
Dim instance As View

The View class provides 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.

NoteNote:

The InfoPath object model does not provide a collection of View objects, but it does provide the ViewInfoCollection class which provides a collection of ViewInfo objects, each of which provides information about the corresponding view it represents. Additionally, the View class provides the ViewInfo property, which allows you to access information about the associated view.

The View object that represents the current view is accessed using the CurrentView property of the XmlForm class. In the following example, first a View object is created to reference the form's currently active view. Then, the ViewInfo property is used to access the ViewInfo object for the view and display its name in a message box.

' Set a reference to the current view.
Dim thisView As View = Me.CurrentView

' Display the view's name.
MessageBox.Show(thisView.ViewInfo.Name)

To change the currently active view, use the SwitchView method of the ViewInfoCollection class as shown in the following example.

Me.ViewInfos.SwitchView("View2")

To force an update of a view to display information that has been programmatically changed in the form's underlying XML document, you can use the ForceUpdate method of the View class, as shown in the following example.

this.CurrentView.ForceUpdate();
Me.CurrentView.ForceUpdate()

System.Object
  Microsoft.Office.InfoPath.View

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Community Additions

ADD
Show:
© 2014 Microsoft