ViewInfoCollection class

Office 2013 and later

Contains a ViewInfo object for each view within a form.


Namespace:  Microsoft.Office.InfoPath
Assembly:  Microsoft.Office.InfoPath (in Microsoft.Office.InfoPath.dll)

public abstract class ViewInfoCollection : IEnumerable

The ViewInfoCollection class implements properties that can be used to access the ViewInfo object associated with each view in a form. The ViewInfoCollection object for a form is accessed through the ViewInfos property of the XmlForm class.

The ViewInfoCollection object can be used to return a reference to a specified ViewInfo object, get the count of the ViewInfo objects, switch views, and return information about a view. It cannot be used to create, add, or remove ViewInfo objects.

In the following example, the ViewInfos property of the XmlForm class is used to set a reference to the ViewInfoCollection of the form. The code then loops through the collection and uses the HideName property of the ViewInfo class to determine whether the view is hidden from the View menu. If it is, the name of the view is displayed in a message box.

// Set a reference to the ViewInfoCollection of the form.
ViewInfoCollection myViewInfos = this.ViewInfos;

// Loop through the collection and display the 
// names of any hidden views.
foreach (ViewInfo myViewInfo in myViewInfos)
      MessageBox.Show("Hidden view: " + myViewInfo.Name);

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