View.SelectText Method (XPathNavigator, String) (Microsoft.Office.InfoPath)

Selects the text contained in an editable control that is bound to the node specified by the XPathNavigator object and ViewContext identifier of the control.

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

Syntax

'Declaration
Public MustOverride Sub SelectText ( _
    xmlNode As XPathNavigator, _
    viewContext As String _
)
'Usage
Dim instance As View
Dim xmlNode As XPathNavigator
Dim viewContext As String

instance.SelectText(xmlNode, viewContext)
public abstract void SelectText (
    XPathNavigator xmlNode,
    string viewContext
)

Parameters

  • viewContext
    The ViewContext identifier for the control in which to select text.

Exceptions

Exception type Condition

InvalidOperationException

The SelectText method was called from an event handler for the Loading event.

ArgumentNullException

The parameters passed to this method are null.

ArgumentException

The parameters passed to this method arenot valid. For example, they are of the wrong type or format.

Remarks

If the specified text is bound to more than one control in the view, you must provide the ViewContext identifier of the control to select text from. You can determine the ViewContext identifier for a control by opening the form template in Design mode, displaying the control's Properties dialog box, and then clicking the Advanced tab.

When the ViewContext identifier is specified, the text that is to be selected must be within that context.

If any of the arguments to the SelectText method are null or are not exposed in the view, then the SelectText method will also raise an exception.

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 Office InfoPath 2007.

Example

In the following example, field1 is bound to more than one control, one of which has the ViewContext identifier of "CTRL2". The SelectText(xmlnode,viewContext) method is used to select the text in field1 from the control with the ViewContext identifier of "CTRL2".

// Create XPathNavigator and select field.
XPathNavigator textNode = 
   CreateNavigator().SelectSingleNode(
   "/my:myFields/my:field1", NamespaceManager);

// Select text in specified field.
CurrentView.SelectText(textNode, "CTRL2");
' Create XPathNavigator and select field.
Dim textNode As XPathNavigator = _
   CreateNavigator().SelectSingleNode( _
   "/my:myFields/my:field1", NamespaceManager)

' Select text in specified field.
CurrentView.SelectText(textNode, "CTRL2")

See Also

Reference

View Class
View Members
Microsoft.Office.InfoPath Namespace