Export (0) Print
Expand All

View.ExecuteAction Method (ActionType)

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

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

Parameters

action

An ActionType enumeration that specifies the action to perform.

Exception typeCondition

InvalidOperationException

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

ArgumentNullException

The parameter passed to this method is null.

ArgumentException

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

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.

NoteNote:

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

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

Community Additions

Show:
© 2014 Microsoft