FormError Class (Microsoft.Office.InfoPath)
Represents an error in the FormErrorCollection of a form.
Namespace: Microsoft.Office.InfoPath
Assembly: Microsoft.Office.InfoPath (in microsoft.office.infopath.dll)
Syntax
'Declaration
Public MustInherit Class FormError
'Usage
Dim instance As FormError
public abstract class FormError
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 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.
Example
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
Inheritance Hierarchy
System.Object
Microsoft.Office.InfoPath.FormError
Thread Safety
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.