Share via


FormErrorCollection.GetErrors Method (FormErrorType) (Microsoft.Office.InfoPath)

Returns all FormError objects of the specified type 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 ( _
    errorType As FormErrorType _
) As FormError()
'Usage
Dim instance As FormErrorCollection
Dim errorType As FormErrorType
Dim returnValue As FormError()

returnValue = instance.GetErrors(errorType)
public abstract FormError[] GetErrors (
    FormErrorType errorType
)

Parameters

  • errorType
    A FormErrorType that specifies the type of errors to return.

Return Value

An array of type FormError that contains errors of the specified type.

Exceptions

Exception type Condition

ArgumentNullException

The parameter passed to this method is null.

ArgumentException

The parameter passed to this method isnot 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 type.

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 Office InfoPath 2007 or in a Web browser.

Example

In the following example, the GetErrors method of the FormErrorCollection class is used to get all errors of type FormErrorType.UserDefined from the form's errors collection. Then the Name property of the FormError class is used to display their names.

FormError[] myErrors;
myErrors = this.Errors.GetErrors(FormErrorType.UserDefined);

foreach(FormError err in myErrors)
{
   MessageBox.Show(err.Name);
}
Dim myErrors As FormError()
myErrors = Me.Errors.GetErrors(FormErrorType.UserDefined)

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

See Also

Reference

FormErrorCollection Class
FormErrorCollection Members
Microsoft.Office.InfoPath Namespace