Gets a reference to an XPathNodeIterator object for iterating over all XML nodes in the current selection of items in a view.
Assembly: Microsoft.Office.InfoPath (in Microsoft.Office.InfoPath.dll)
'Declaration PublicMustOverrideFunctionGetSelectedNodesAsXPathNodeIterator 'Usage DiminstanceAsViewDimreturnValueAsXPathNodeIteratorreturnValue = instance.GetSelectedNodes()
If no items are selected in a view, or if only text is selected, then the XPathNodeIterator object returned by the GetSelectedNodes method has nothing to iterate over.
The GetSelectedNodes method will not return nodes based on the current selection if used in the event handler for the Clicked event of a button in the view, because the focus is lost from the control that is intended to be in context. To avoid this behavior, use GetSelectedNodes from a custom task pane, menu or toolbar.
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 only from code running in forms opened in Microsoft InfoPath Filler.
In the following example, the SelectNodes method is used to select the nodes in the first row of a Repeating Table control bound to group2. The GetSelectedNodes method is then used to return a collection of nodes based on the current selection. Finally, the code loops through the collection of nodes displays the name, inner XML, and value of each node.
' Create XPathNavigator and specify XPath for nodes. Dim repeatingTableRow1 As XPathNavigator = _ CreateNavigator().SelectSingleNode( _ "/my:myFields/my:group1/my:group2", NamespaceManager) ' Select nodes in specified XPathNavigator. CurrentView.SelectNodes(repeatingTableRow1) ' Get selected nodes. Dim selectedNodes As XPathNodeIterator = _ CurrentView.GetSelectedNodes() ' Display the count of selected nodes. MessageBox.Show(selectedNodes.Count.ToString()) ' Loop through collection and display information. Dim selectedNode As XPathNavigator For Each selectedNode In selectedNodes MessageBox.Show(selectedNode.Name) MessageBox.Show(selectedNode.InnerXml) MessageBox.Show(selectedNode.Value) Next