Occurs when the Submit command is used from the user interface, or the Submit method is used.
Assembly: Microsoft.Office.InfoPath (in Microsoft.Office.InfoPath.dll)
The developer attempted to bind the event in some location other than the InternalStartup method.
The event is not meant to be instantiated by the developer in form code. You should only add event handlers for form-level events from the Microsoft InfoPath 2010 design mode user interface. When you add an event handler to your form template from the design mode user interface, InfoPath generates code in the InternalStartup method of your form code file using the EventManager class and the member of the FormEvents class to bind the event to its event handler. For information on how to add event handlers in InfoPath design mode, see How to: Add an Event Handler.
The event is raised only if the form template has the Perform custom action using Code option set in the Submit Options dialog box.
The event is bound using the SubmitEventHandler delegate.
If event handler code uses the CancelableArgs property to set the strings of the Message or MessageDetails properties, but the CancelableArgs.Cancel property is left to the default setting of false, then a success message will be displayed with the text of the Message and MessageDetails properties. This message will override the Show a success or failure message and On success custom message settings in the Form Submit Options dialog box.
Similarly, if the event handler code sets the Message or MessageDetails strings, and sets CancelableArgs.Cancel to true, then a failure message will be shown, the message will be displayed with the text of the Message and MessageDetails properties, overriding the Form Submit Options dialog box settings.
If the event handler code leaves both Message and MessageDetails properties at the default value of a null reference (Nothing in Visual Basic), but sets CancelableArgs.Cancel to true, then the submit operation is considered to have failed. Whether a failure message will be shown and what the message will be is determined by the settings in the Submit Options dialog box.
This type or member can be accessed from code running in forms opened in Microsoft InfoPath Filler or in a Web browser.
In the following example, the event handler for the event is used to prevent the form from being submitted if the form has not been saved.