FormErrorCollection Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Contains a FormError object for each error in the current form.
public ref class FormErrorCollection abstract : System::Collections::IEnumerable
public abstract class FormErrorCollection : System.Collections.IEnumerable
type FormErrorCollection = class
interface IEnumerable
Public MustInherit Class FormErrorCollection
Implements IEnumerable
- Inheritance
-
FormErrorCollection
- Implements
Examples
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);
Dim root, txtbox As XPathNavigator
' Create XPathNavigator for main data source.
root = Me.MainDataSource.CreateNavigator()
' Create XPathNavigator positioned at field to add error.
txtbox = root.SelectSingleNode("//my:field1", Me.NamespaceManager)
' Get form's collection of errors and add error.
Me.Errors.Add(txtbox, "Field1Error", "Short error message.",
"Detailed error description.", 102057, ErrorMode.Modeless)
Remarks
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.
Note: Custom errors can also be created using the ReportError method of the XmlValidatingEventArgs class.
To access the FormErrorCollection object associated with a form, use the Errors property of the XmlForm class.
FormErrorCollection myErrors = this.Errors;
Dim myErrors As FormErrorCollection = Me.Errors
Constructors
FormErrorCollection() |
Properties
Count |
Gets the number of FormError objects in the FormErrorCollection object associated with the current form. |
Item[Int32] |
Gets a FormError object from the FormErrorCollection object associated with the current form by index value. |
Methods
Add(XPathNavigator, String, String, String, Int32, ErrorMode) |
Creates and adds a new FormError to the FormErrorCollection object associated with the current form. |
Add(XPathNavigator, String, String, String, Int32) |
Creates and adds a new FormError to the FormErrorCollection object associated with the current form. |
Add(XPathNavigator, String, String, String) |
Creates and adds a new FormError to the FormErrorCollection object associated with the current form. |
Add(XPathNavigator, String, String) |
Creates and adds a new FormError to the FormErrorCollection object associated with the current form. |
Delete(FormError) |
Deletes the specified FormError from the FormErrorCollection object associated with the current form. |
Delete(String) |
Deletes all FormError objects of the specified name from the FormErrorCollection object associated with the current form. |
DeleteAll() |
Deletes all of the FormError objects contained in the FormErrorCollection object associated with the current form. |
GetEnumerator() |
Gets an IEnumerator object that iterates over all entries in the collection. |
GetErrors(FormErrorType) |
Returns all FormError objects of the specified type from the FormErrorCollection object associated with the current form. |
GetErrors(String) |
Returns all FormError objects of the specified name from the FormErrorCollection object associated with the current form. |