_XDocument2.DataObjects Property

Gets a reference to the DataObjectsCollection collection that is associated with a form.

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

Syntax

'Declaration
ReadOnly Property DataObjects As DataObjectsCollection
    Get
'Usage
Dim instance As _XDocument2
Dim value As DataObjectsCollection

value = instance.DataObjects
DataObjectsCollection DataObjects { get; }

Property Value

Type: Microsoft.Office.Interop.InfoPath.SemiTrust.DataObjectsCollection

Implements

_XDocument.DataObjects

Remarks

The DataObjects collection provides programmatic access to a form's secondary data sources. Each secondary data source is contained in a DataSourceObject object within the DataObjects collection.

Important

This member can be accessed only by forms running in the same domain as the currently open form, or by forms that have been granted cross-domain permissions.

Examples

In the following example, the DataObjects property of the XDocument object is used to set a reference to the "CityList" secondary data source:

object objDataObject;
objDataObject = thisXDocument.DataObjects["CityList"];

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

[InfoPathEventHandler(MatchPath="ShowDataObjectNames", EventType=InfoPathEventType.OnClick)]
public void ShowDataObjectNames_OnClick(DocActionEvent e)
{
 // Set a reference to the DataObjects collection.
 DataObjectsCollection dataObjects = thisXDocument.DataObjects;

 // Loop through the collection and display the name
 // of each DataObject object that it contains.
 for (int i=0; i < dataObjects.Count; i++)
 {
  thisXDocument.UI.Alert("Data object " + i + ": " + dataObjects[i].Name);
 }
}

See Also

Reference

_XDocument2 Interface

_XDocument2 Members

DataObjects Overload

Microsoft.Office.Interop.InfoPath.SemiTrust Namespace