ViewInfosCollection Interface
Collapse the table of content
Expand the table of content
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here. ArchiveDisclaimer

ViewInfosCollection Interface

Contains a ViewInfoObject object for each view within a Microsoft InfoPath 2010 form.

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

public interface ViewInfosCollection : ViewInfos

This type is a wrapper for a coclass that is required by managed code for COM interoperability. Use this type to access the members of the COM interface implemented by this coclass. For information about the COM interface, including a link to descriptions of its members, seeViewInfos.

The ViewInfosCollection collection implements properties that can be used to access a form's associated ViewInfoObject object, and it is accessible through the ViewInfos property of the XDocument object.

The ViewInfosCollection collection can be used only to get the count of the ViewInfoObject objects that it contains or to return a reference to a specified ViewInfoObject object. It cannot be used to create, add, or remove ViewInfoObject objects.

In the following example, implemented as an OnClick event handler for a button on a form, the ViewInfos property of the XDocument object is used to set a reference to the ViewInfos collection. The code then loops through the collection and displays the positional index and name of each ViewInfo object that it contains.

[InfoPathEventHandler(MatchPath="ShowViewNames", EventType=InfoPathEventType.OnClick)]
public void ShowViewNames_OnClick(DocActionEvent e)
 // Set a reference to the ViewInfos collection.
 ViewInfos viewInfos= thisXDocument.ViewInfos;

 // Loop through the collection and display the name
 // of each ViewInfo object that it contains.
 for (int i=0; i < viewInfos.Count; i++)
  thisXDocument.UI.Alert("View name " + i + ": " + 
© 2016 Microsoft