Modifica

Condividi tramite


Errors.Add(Object, String, String, String, Int32, String) Method

Definition

Adds an ErrorObject to ErrorsCollection and returns a reference to the new Error object.

public Microsoft.Office.Interop.InfoPath.ErrorObject Add (object varNode, string bstrConditionName, string bstrShortErrorMessage, string bstrDetailedErrorMessage = "", int lErrorCode = 0, string bstrType = "modeless");
abstract member Add : obj * string * string * string * int * string -> Microsoft.Office.Interop.InfoPath.ErrorObject
Public Function Add (varNode As Object, bstrConditionName As String, bstrShortErrorMessage As String, Optional bstrDetailedErrorMessage As String = "", Optional lErrorCode As Integer = 0, Optional bstrType As String = "modeless") As ErrorObject

Parameters

varNode
Object

The XML node that the error will be associated with.

bstrConditionName
String

The name of the error.

bstrShortErrorMessage
String

The short message for the error.

bstrDetailedErrorMessage
String

The detailed message for the error.

lErrorCode
Int32

The error code of the error.

bstrType
String

Default value is "modeless". The type of error processing. The other supported value is "modal".

Returns

An ErrorObject object which represents the newly created Error.

Examples

//Add an error to the node
IXMLDOMDocument myDOM = thisXDocument.DOM;
IXMLDOMNode myNode = myDOM.selectSingleNode("my:myFields/my:aGroup/my:field1");
thisXDocument.Errors.<span class="label">Add</span>(myNode,"condition","short","detail",102057,"modeless");

Remarks

The Add method is used to create custom error messages in a Microsoft InfoPath form. There are two types of errors that can be created using the Add method:

modelessThe user is notified of the error with an inline alert and can choose to return to the previous value with an undo operation
modalThe user is notified of the error with a dialog box alert. After clicking OK in the dialog box alert, the error will appear as an inline alert and the user can choose to return to the previous value with an undo operation

Note: Custom errors can also be created using the ReportError(Object, String, Boolean, String, Int32, String) method.

Applies to