Edit

Share via


FormError Class

Definition

Represents an error in the FormErrorCollection of a form.

public ref class FormError abstract
public abstract class FormError
type FormError = class
Public MustInherit Class FormError
Inheritance
FormError

Examples

In the following example, clicking the Button control gets the first error in the FormErrorCollection of the form, and then displays the values of all of the properties of the FormError object.

public void ErrorBtn_Clicked(object sender, ClickedEventArgs e)
{
   FormError er = this.Errors[0];
   MessageBox.Show("Short message: " + er.Message);
   MessageBox.Show("Detailed message: " + er.DetailedMessage); 
   MessageBox.Show("Error code: " + er.ErrorCode);
   MessageBox.Show("Error name: " + er.Name);
   MessageBox.Show("Error type: " + er.FormErrorType.ToString());
   MessageBox.Show("Error site XML: " + er.Site.OuterXml.ToString());
}
Public Sub ErrorBtn_Clicked(ByVal sender As Object, _
   ByVal e As ClickedEventArgs)
   FormError er = Me.Errors(0)
   MessageBox.Show("Short message: " & er.Message)
   MessageBox.Show("Detailed message: " & er.DetailedMessage) 
   MessageBox.Show("Error code: " & er.ErrorCode)
   MessageBox.Show("Error name: " & er.Name);
   MessageBox.Show("Error type: " & er.FormErrorType.ToString())
   MessageBox.Show("Error site XML: " & er.Site.OuterXml.ToString())
End Sub

Remarks

Each FormError object in an InfoPath form is associated with a node in the form's underlying XML document. When data validation fails for a particular node, InfoPath creates a FormError object and places it in the FormErrorCollection associated with the form.

There are three types of data validation errors that can occur in an InfoPath form. They can be determined using the FormErrorType property of the FormError class:

  • FormErrorType.SchemaValidation   Data validation failed as a result of an XML Schema–defined constraint.
  • FormErrorType.SystemGenerated   Data validation failed as a result of constraints defined in the form definition (.xsf) file or as a result of form code calling the Microsoft.Office.InfoPath.XmlValidatingEventArgs.ReportError method of the XmlValidatingEventArgs class.
  • FormErrorType.UserDefined   Data validation failed as a result of a custom error defined using the Add method of the FormErrorsCollection class.

Constructors

FormError()

Properties

DetailedMessage

Gets or sets the detailed message displayed for the FormError object.

ErrorCode

Gets or sets the numeric error code value of a FormError object.

FormErrorType

Gets the type of the FormError object.

Message

Gets or sets the short message displayed for a FormError object.

Name

Gets the name of the FormError object.

Site

Gets an XPathNavigator that is positioned at the node of a form's underlying XML document that is associated with a FormError object.

Applies to