Edit

Share via


View.ExecuteAction Method

Definition

Overloads

ExecuteAction(ActionType)

Executes an editing command against a form's underlying XML document, based on the data currently selected in the view.

ExecuteAction(ActionType, String)

Executes an editing command against a form's underlying XML document, based on the specified field or group.

ExecuteAction(ActionType)

Executes an editing command against a form's underlying XML document, based on the data currently selected in the view.

public:
 abstract void ExecuteAction(Microsoft::Office::InfoPath::ActionType action);
public abstract void ExecuteAction (Microsoft.Office.InfoPath.ActionType action);
abstract member ExecuteAction : Microsoft.Office.InfoPath.ActionType -> unit
Public MustOverride Sub ExecuteAction (action As ActionType)

Parameters

action
ActionType

An ActionType enumeration that specifies the action to perform.

Exceptions

The ExecuteAction 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 ExecuteAction(action) method of the View class is used to delete the currently selected data and place it on the clipboard.

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

// Select text in specified field.
CurrentView.SelectText(textNode);

// Cut selected text.
CurrentView.ExecuteAction(ActionType.Cut);
' Create XPathNavigator and select field.
Dim textNode As XPathNavigator = _
   CreateNavigator().SelectSingleNode( _
   "/my:myFields/my:field1", NamespaceManager)

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

' Cut selected text.
CurrentView.ExecuteAction(ActionType.Cut)

Remarks

The ExecuteAction method is used to programmatically perform built-in editing actions against a form's underlying XML document, based on the selected context in a view.

The action that is executed will be the same action that would be used when clicking on an equivalent menu or toolbar button; namely one for which the button element in the .xsf file has corresponding xmlToEdit and action attributes. As with using a button, it will act on the selected context (and in the case where the selection would lead the button to be disabled, then the ExecuteAction method will have no effect).

It is possible to first set the selection context by using the SelectNodes method or SelectText method, then call the ExecuteAction method to act on that context.

Note: In some cases, calling the ExecuteAction method from an event handler for the Clicked event of a button in the view may cause an error. This is because the selected context changes to the button when the button is clicked. In this case, it is better to use a button or link on a custom task pane, menu, or toolbar to call the ExecuteAction method.

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.

Applies to

ExecuteAction(ActionType, String)

Executes an editing command against a form's underlying XML document, based on the specified field or group.

public:
 abstract void ExecuteAction(Microsoft::Office::InfoPath::ActionType action, System::String ^ xmlToEdit);
public abstract void ExecuteAction (Microsoft.Office.InfoPath.ActionType action, string xmlToEdit);
abstract member ExecuteAction : Microsoft.Office.InfoPath.ActionType * string -> unit
Public MustOverride Sub ExecuteAction (action As ActionType, xmlToEdit As String)

Parameters

action
ActionType

An ActionType enumeration that specifies the action to perform.

xmlToEdit
String

The XmlToEdit identifier of the field or group to which to apply the editing action.To determine the XmlToEdit identifier of a field or group, right-click the control to which the field or group is bound, click <Control Type> Properties, and then click the Advanced tab. The XmlToEdit value is displayed in the Code section of the tab.

Exceptions

The ExecuteAction 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, the ExecuteAction(action, xmlToEdit) method of the View class is used to insert data into the specified group using the ActionType.XCollectionInsert action.

this.CurrentView.ExecuteAction(ActionType.XCollectionInsert, 
   "group1_1");

Me.CurrentView.ExecuteAction(ActionType.XCollectionInsert, "group1_1")

Remarks

The ExecuteAction method is used to programmatically perform built-in editing actions against a form's underlying XML document, based on the selected context in a view.

The action that is executed will be the same action that would be used when clicking on an equivalent menu or toolbar button; namely one for which the button element in the .xsf file has corresponding xmlToEdit and action attributes. As with using a button, the action will be based on current selection: it will act on the selected context (and in the case where the selection would lead the button to be disabled, then the ExecuteAction method will have no effect).

You can determine the XmlToEdit identifier for a control or group on an InfoPath form in the Designer by displaying the control's Properties dialog box, and then clicking the Advanced tab.

Note: In some cases, calling the ExecuteAction method from an event handler for the Clicked event of a button in the view may cause an error. This is because the selected context changes to the button when the button is clicked. In this case, it is better to use a button or link on a custom task pane, menu, or toolbar to call the ExecuteAction method.

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.

Applies to