_XDocument4.DataObjects Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets a reference to the DataObjectsCollection collection that is associated with a Microsoft InfoPath form.
public:
property Microsoft::Office::Interop::InfoPath::DataObjectsCollection ^ DataObjects { Microsoft::Office::Interop::InfoPath::DataObjectsCollection ^ get(); };
public Microsoft.Office.Interop.InfoPath.DataObjectsCollection DataObjects { get; }
member this.DataObjects : Microsoft.Office.Interop.InfoPath.DataObjectsCollection
Public ReadOnly Property DataObjects As DataObjectsCollection
Property Value
Returns DataObjectsCollection.
Implements
Examples
In the following example, the DataObjects property of the XDocument object is used to set a reference to the "CityList" secondary data source:
DataSourceObject myDataObject =
(DataSourceObject)thisXDocument.<span class="label">DataObjects</span>["CityList"];
Dim myDataObject As DataSourceObject = _
DirectCast(thisXDocument.<span class="label">DataObjects</span>["CityList"], DataSourceObject)
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.<span class="label">DataObjects</span>;
// 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);
}
}
In the following example, the DataObjects property of the XDocument object is used to set a reference to the "CityList" secondary data source:
DataSourceObject myDataObject =
(DataSourceObject)thisXDocument.<span class="label">DataObjects</span>["CityList"];
Dim myDataObject As DataSourceObject = _
DirectCast(thisXDocument.<span class="label">DataObjects</span>["CityList"], DataSourceObject)
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.<span class="label">DataObjects</span>;
// 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);
}
}
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.
Applies to
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기