Share via


View2.SelectNodes Method

Selects a range of nodes in a view based on the specified starting XML Document Object Model (DOM) node, the ending XML DOM node, and the view context.

Namespace: Microsoft.Office.Interop.InfoPath
Assembly: Microsoft.Office.Interop.InfoPath (in microsoft.office.interop.infopath.dll)

Syntax

'Declaration
'Usage

Parameters

  • pxnStartNode
    The XML DOM node that begins the range.
  • varEndNode
    The XML DOM node that ends the range. If not specified, only the starting XML DOM node will be used.
  • varViewContext
    The ID of the control that is used for the context, which is an element with the specified view context of xd:CtrlId.

Remarks

If a view context is specified, all of the XML DOM nodes that are to be selected must be within that context.

If any of the arguments to the SelectNodes method are null or are not exposed in the view, the SelectNodes method will return an error. In addition, if there are more than one set of view elements which map to the same specified XML DOM nodes, within the specified view context, then the SelectNodes method will also return an error.

Note

The SelectNodes method requires that the nodes be structurally selectable in the view.

Example

In the following example, the SelectNodes method of the ViewObject object is used to set selection on a single item in the view, corresponding to the specified XML DOM node. Using the GetSelectedNodes method of the View object, the code then determines whether the selection has been successful by displaying information about the XML DOM node in a message box. This example requires a repeating table named group1. The first occurrence is selected:

XMLNodesCollection selectedNodes;
IXMLDOMNode group1;
group1 = thisXDocument.DOM.selectSingleNode(@"//my:group1");
thisXDocument.View.SelectNodes(group1, Type.Missing, Type.Missing);
selectedNodes = thisXDocument.View.GetSelectedNodes();
if (selectedNodes.Count > 0)
 {
  thisXDocument.UI.Alert(selectedNodes[0].nodeName + "\n\n" + selectedNodes[0].text);
 }

See Also

Reference

View2 Interface
View2 Members
Microsoft.Office.Interop.InfoPath Namespace