BaseEdit.ErrorText Property

Gets or sets the error description for the editor.

Namespace: DevExpress.XtraEditors

Assembly: DevExpress.XtraEditors.v20.1.dll

Declaration

[Browsable(false)]
public string ErrorText { get; set; }
<Browsable(False)>
Public Property ErrorText As String

Property Value

Type Description
String

A string value specifying the error description for the editor.

Remarks

If the ErrorText property is specified, the editor displays an error icon at the near edge. The tooltip contains the error description. To display the tooltip, hover the error icon with the mouse pointer.

The default error icon (ColumnView.SetColumnError_ErrorGlyph) is specified by the static BaseEdit.DefaultErrorIcon property. To customize the error icon for a specific editor, use the BaseEdit.ErrorImageOptions property.

You can specify an error when you validate a value in a RepositoryItem.Validating event handler. For example, if the value is not valid, you may leave the editor focused until the value is corrected. Use the ErrorText property to informe a user how to correct the value.

using DevExpress.XtraEditors;

private void textEdit1_Validating(object sender, CancelEventArgs e) {
    TextEdit textEdit = sender as TextEdit;
    string editValue = textEdit.EditValue as string;
    Regex regex = new Regex("^[a-zA-Z0-9 ]*$");
    if (!regex.IsMatch(editValue)) {
        textEdit.ErrorText = "The name should only contain alphanumeric characters";
        textEdit.ErrorImageOptions.ImageUri.Uri = "SpellCheckAsYouType;Size16x16";
        e.Cancel = true;
    }
}
TIP

You can also use the ErrorProvider component as this provides a flexible way to indicate errors, especially for standalone data-bound controls.

See Also