DataDOMEvent.ReturnMessage Property

Gets or sets the error message that will be returned if the data validation event is not successful.

Namespace: Microsoft.Office.Interop.InfoPath
Assembly: Microsoft.Office.Interop.InfoPath (in

Used in conjunction with the ReturnStatus property, the ReturnMessage property displays a message box to the user with the specified text message.

In the following example, the ReturnMessage property of the DataDOMEventObject object is used to display a message to the user if the data validation for the XML DOM node fails:

public void qtty_OnBeforeChange(DataDOMEvent e)
  if (e.NewValue.ToString() == "")
   e.ReturnMessage = "You must supply a value for this field.";
   e.ReturnStatus = false;

Community Additions