XmlForm::DataSources property

Office 2013 and later

Gets the DataSourceCollection object associated with the form.

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

No code example is currently available or this language may not be supported.

Property value

Type: Microsoft.Office.InfoPath.DataSourceCollection
A DataSourceCollection that contains any DataSource objects associated with the form.

The DataSourceCollection object contains a collection of DataSource objects that represent all external (secondary) data sources associated with the form template. The DataSourceCollection object also contains a DataSource object that represents the main data source of the form. This means that developers will have two ways to return the DataSource object that represents the main data source: by using DataSources[""] or by using the MainDataSource property.

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.

This type or member can be accessed from code running in forms opened in Microsoft InfoPath Filler or in a Web browser.

In the following code example, the DataSources property of the XmlForm class is used to set a reference to the "CityList" secondary data source.

No code example is currently available or this language may not be supported.

In the following code example, which implements an event handler for a Button control on a form, the DataSources property of the XmlForm object is used to set a reference to the DataSourceCollection of the form. The code loops through the collection and displays the positional index and name of each DataSource object that it contains.

No code example is currently available or this language may not be supported.
Show: