Edit

Share via


FormErrorCollection.GetErrors Method

Definition

Overloads

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.

GetErrors(FormErrorType)

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

public:
 abstract cli::array <Microsoft::Office::InfoPath::FormError ^> ^ GetErrors(Microsoft::Office::InfoPath::FormErrorType errorType);
public abstract Microsoft.Office.InfoPath.FormError[] GetErrors (Microsoft.Office.InfoPath.FormErrorType errorType);
abstract member GetErrors : Microsoft.Office.InfoPath.FormErrorType -> Microsoft.Office.InfoPath.FormError[]
Public MustOverride Function GetErrors (errorType As FormErrorType) As FormError()

Parameters

errorType
FormErrorType

A FormErrorType that specifies the type of errors to return.

Returns

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

Exceptions

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

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

Examples

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

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

Applies to

GetErrors(String)

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

public:
 abstract cli::array <Microsoft::Office::InfoPath::FormError ^> ^ GetErrors(System::String ^ name);
public abstract Microsoft.Office.InfoPath.FormError[] GetErrors (string name);
abstract member GetErrors : string -> Microsoft.Office.InfoPath.FormError[]
Public MustOverride Function GetErrors (name As String) As FormError()

Parameters

name
String

The name of the errors to return.

Returns

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

Exceptions

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

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

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

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.

Applies to