Skip to main content

ValidationEventArgs.SetError(Object) Method

Displays an error within the editor.

Namespace: DevExpress.Xpf.Editors

Assembly: DevExpress.Xpf.Core.v14.2.dll

#Declaration

public void SetError(
    object errorContent
)

#Parameters

Name Type Description
errorContent Object

An object that specifies the error content.

#Remarks

The SetError method automatically sets the ValidationEventArgs.IsValid property to false. If the errorContent parameter is set to an empty string or null, the ValidationEventArgs.IsValid property is set to true and the error isn't displayed.


using DevExpress.Xpf.Editors.Internal;
//...
private void textEdit_Validate(object sender, ValidationEventArgs e) {
    if(Convert.ToDouble(e.Value) <= 0)
        e.SetError("Negative values are not allowed. Please correct.", ErrorType.Critical);
}

The image below shows the result:

Validation_ErrorContent

See Also