Edit

Share via


View.SelectText Method

Definition

Overloads

SelectText(XPathNavigator)

Selects the text contained in an editable control that is bound to the node specified by the XPathNavigator object passed to this method.

SelectText(XPathNavigator, String)

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.

SelectText(XPathNavigator)

Selects the text contained in an editable control that is bound to the node specified by the XPathNavigator object passed to this method.

public:
 abstract void SelectText(System::Xml::XPath::XPathNavigator ^ xmlNode);
public abstract void SelectText (System.Xml.XPath.XPathNavigator xmlNode);
abstract member SelectText : System.Xml.XPath.XPathNavigator -> unit
Public MustOverride Sub SelectText (xmlNode As XPathNavigator)

Parameters

xmlNode
XPathNavigator

An object that specifies the text to select.

Exceptions

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

The parameter passed to this method is a null reference (Nothing in Visual Basic).

The parameter passed to this method is not valid. For example, it is of the wrong type or format.

Examples

In the following example, the SelectText(xmlNode) method is used to select the text in field1.

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

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

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

Remarks

If the specified text is bound to more than one control in the view, using this SelectText method will raise an exception. To avoid this, you must use the SelectText(XPathNavigator, String) method which allows you to specify the ViewContext identifier of the control that contains the text you want to select.

In addition, if the argument to the SelectText method is a null reference (Nothing in Visual Basic) or is 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 from code running in forms opened in Microsoft InfoPath Filler or in a Web browser.

Applies to

SelectText(XPathNavigator, String)

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.

public:
 abstract void SelectText(System::Xml::XPath::XPathNavigator ^ xmlNode, System::String ^ viewContext);
public abstract void SelectText (System.Xml.XPath.XPathNavigator xmlNode, string viewContext);
abstract member SelectText : System.Xml.XPath.XPathNavigator * string -> unit
Public MustOverride Sub SelectText (xmlNode As XPathNavigator, viewContext As String)

Parameters

xmlNode
XPathNavigator

An object that specifies the text to select.

viewContext
String

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

Exceptions

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

The parameters passed to this method are a null reference (Nothing in Visual Basic).

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

Examples

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")

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 a null reference (Nothing in Visual Basic) 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 from code running in forms opened in Microsoft InfoPath Filler or in a Web browser.

Applies to