Contains a FormError object for each error in the current form.
Assembly: Microsoft.Office.InfoPath (in Microsoft.Office.InfoPath.dll)
A FormErrorCollection object contains a collection of FormError objects that represent all errors occurring in the associated form. The collection of errors includes validation errors, system-generated errors, and user-defined (custom) errors. The FormErrorCollection class provides properties and methods for adding, deleting, and gaining access to the FormError objects that it contains. You cannot delete validation or system-generated errors from this collection.
In addition to managing the errors generated by InfoPath, the FormErrorCollection class can also be used to create custom errors using the Add method.
In the following example, first an XPathNavigator object is positioned at the field with which to associate an error. Then, the XPathNavigator and error message details are passed to the Add method of the FormErrorCollection class to add the error to the form's error collection.
XPathNavigator root, txtbox; // Create XPathNavigator for main data source. root = this.MainDataSource.CreateNavigator(); // Create XPathNavigator positioned at field to associate with error. txtbox = root.SelectSingleNode("//my:field1", this.NamespaceManager); // Get form's collection of errors and add error. this.Errors.Add(txtbox, "Field1Error", "Short error message.", "Detailed error description.", 102057, ErrorMode.Modeless);