FormErrorCollection.GetErrors method (String)

Returns all FormError objects of the specified name from the FormErrorCollection object associated with the current form.

Namespace:  Microsoft.Office.InfoPath
Assembly:  Microsoft.Office.InfoPath (in Microsoft.Office.InfoPath.dll)

Syntax

'Declaration
Public MustOverride Function GetErrors ( _
    name As String _
) As FormError()
'Usage
Dim instance As FormErrorCollection
Dim name As String
Dim returnValue As FormError()

returnValue = instance.GetErrors(name)
public abstract FormError[] GetErrors(
    string name
)

Parameters

Return value

Type: []
An array of type FormError that contains all errors of type FormErrorType.UserDefined with the specified name.

Exceptions

Exception Condition
ArgumentNullException

The parameter passed to this method is a null reference (Nothing in Visual Basic).

ArgumentException

The parameter passed to this method is not valid. For example, it is of the wrong type or format.

Remarks

An empty array is returned if there are no errors in the collection of the specified name.

This member can be accessed only by forms running in the same domain as the currently open form, or by forms that have been granted cross-domain permissions.

This type or member can be accessed from code running in forms opened in Microsoft InfoPath Filler or in a Web browser.

Examples

In the following example, the GetErrors method of the FormErrorCollection class is used to get all errors named DateFormatError from the form's errors collection. The Message property of the FormError class is then used to display their error messages.

FormError[] myErrors;
myErrors = this.Errors.GetErrors("DateFormatError");

foreach(FormError err in myErrors)
{
   MessageBox.Show(err.Message);
}
Dim myErrors As FormError()
myErrors = Me.Errors.GetErrors("DateFormatError")

For Each FormError err In myErrors
   MessageBox.Show(err.Message);
Next

See also

Reference

FormErrorCollection class

FormErrorCollection members

GetErrors overload

Microsoft.Office.InfoPath namespace