FormErrorCollection.Add Method
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.
Overloads
Add(XPathNavigator, String, String) |
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, String, Int32) |
Creates and adds a new FormError to the FormErrorCollection object associated with the current form. |
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)
Creates and adds a new FormError to the FormErrorCollection object associated with the current form.
public:
abstract Microsoft::Office::InfoPath::FormError ^ Add(System::Xml::XPath::XPathNavigator ^ context, System::String ^ name, System::String ^ message);
public abstract Microsoft.Office.InfoPath.FormError Add (System.Xml.XPath.XPathNavigator context, string name, string message);
abstract member Add : System.Xml.XPath.XPathNavigator * string * string -> Microsoft.Office.InfoPath.FormError
Public MustOverride Function Add (context As XPathNavigator, name As String, message As String) As FormError
Parameters
- context
- XPathNavigator
An XPathNavigator object positioned at the node that the error will be associated with.
- name
- String
The name of the error (cannot be blank).
- message
- String
The short message for the error.
Returns
A reference to the new FormError that was added to the collection.
Exceptions
The parameters passed to this method are a null reference (Nothing in Visual Basic).
The parameters passed to this method are not valid. For example, they are of the wrong type or format.
Examples
In the following example, first an XPathNavigator object is positioned at the field with which to associate an error. Then, the XPathNavigator, name, and message 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.");
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.")
Remarks
The FormErrorType of the new FormError will be set to UserDefined.
Note: It is possible to add multiple errors with the same name
parameter value to different context
nodes. However, if you add an error with the same name to the same context
node twice, the second error added overwrites the first one.
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
Add(XPathNavigator, String, String, String)
Creates and adds a new FormError to the FormErrorCollection object associated with the current form.
public:
abstract Microsoft::Office::InfoPath::FormError ^ Add(System::Xml::XPath::XPathNavigator ^ context, System::String ^ name, System::String ^ message, System::String ^ messageDetails);
public abstract Microsoft.Office.InfoPath.FormError Add (System.Xml.XPath.XPathNavigator context, string name, string message, string messageDetails);
abstract member Add : System.Xml.XPath.XPathNavigator * string * string * string -> Microsoft.Office.InfoPath.FormError
Public MustOverride Function Add (context As XPathNavigator, name As String, message As String, messageDetails As String) As FormError
Parameters
- context
- XPathNavigator
An XPathNavigator object positioned at the node that the error will be associated with.
- name
- String
The name of the error (cannot be blank).
- message
- String
The short message for the error.
- messageDetails
- String
The detailed message for the error.
Returns
A reference to the new FormError that was added to the collection.
Exceptions
The parameters passed to this method are not valid. For example, they are of the wrong type or format.
The parameters passed to this method are a null reference (Nothing in Visual Basic).
Examples
In the following example, first an XPathNavigator object is positioned at the field with which to associate an error. Then, the XPathNavigator, name, message, and detailed message 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
The FormErrorType of the new FormError will be set to UserDefined.
Note: It is possible to add multiple errors with the same name
parameter value to different context
nodes. However, if you add an error with the same name to the same context
node twice, the second error added overwrites the first one.
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
Add(XPathNavigator, String, String, String, Int32)
Creates and adds a new FormError to the FormErrorCollection object associated with the current form.
public:
abstract Microsoft::Office::InfoPath::FormError ^ Add(System::Xml::XPath::XPathNavigator ^ context, System::String ^ name, System::String ^ message, System::String ^ messageDetails, int errorCode);
public abstract Microsoft.Office.InfoPath.FormError Add (System.Xml.XPath.XPathNavigator context, string name, string message, string messageDetails, int errorCode);
abstract member Add : System.Xml.XPath.XPathNavigator * string * string * string * int -> Microsoft.Office.InfoPath.FormError
Public MustOverride Function Add (context As XPathNavigator, name As String, message As String, messageDetails As String, errorCode As Integer) As FormError
Parameters
- context
- XPathNavigator
An XPathNavigator object positioned at the node that the error will be associated with.
- name
- String
The name of the error (cannot be blank).
- message
- String
The short message for the error.
- messageDetails
- String
The detailed message for the error.
- errorCode
- Int32
The error code of the error.
Returns
A reference to the new FormError that was added to the collection.
Exceptions
The parameters passed to this method are not valid. For example, they are of the wrong type or format.
The parameters passed to this method are a null reference (Nothing in Visual Basic).
Examples
In the following example, first an XPathNavigator object is positioned at the field with which to associate an error. Then, the XPathNavigator, name, message, detailed message, error code, and error number 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);
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)
Remarks
The FormErrorType of the new FormError will be set to UserDefined.
Note: It is possible to add multiple errors with the same name
parameter value to different context
nodes. However, if you add an error with the same name to the same context
node twice, the second error added overwrites the first one.
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
Add(XPathNavigator, String, String, String, Int32, ErrorMode)
Creates and adds a new FormError to the FormErrorCollection object associated with the current form.
public:
abstract Microsoft::Office::InfoPath::FormError ^ Add(System::Xml::XPath::XPathNavigator ^ context, System::String ^ name, System::String ^ message, System::String ^ messageDetails, int errorCode, Microsoft::Office::InfoPath::ErrorMode errorMode);
public abstract Microsoft.Office.InfoPath.FormError Add (System.Xml.XPath.XPathNavigator context, string name, string message, string messageDetails, int errorCode, Microsoft.Office.InfoPath.ErrorMode errorMode);
abstract member Add : System.Xml.XPath.XPathNavigator * string * string * string * int * Microsoft.Office.InfoPath.ErrorMode -> Microsoft.Office.InfoPath.FormError
Parameters
- context
- XPathNavigator
An XPathNavigator object positioned at the node that the error will be associated with.
- name
- String
The name of the error (cannot be blank).
- message
- String
The short message for the error.
- messageDetails
- String
The detailed message for the error.
- errorCode
- Int32
The error code of the error.
Returns
A reference to the new FormError that was added to the collection.
Exceptions
The parameters passed to this method arenot valid. For example, they are of the wrong type or format.
The parameters passed to this method are a null reference (Nothing in Visual Basic).
Examples
In the following example, first an XPathNavigator object is positioned at the field with which to associate an error. Then, the XPathNavigator, name, message, detailed message, error code, error number, and error display mode 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
The FormErrorType of the new FormError will be set to UserDefined.
Note: It is possible to add multiple errors with the same name
parameter value to different context
nodes. However, if you add an error with the same name to the same context
node twice, the second error added overwrites the first one.
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.