Skip to main content
A newer version of this page is available. .

BaseEdit.ErrorText Property

Gets or sets the error description for the editor.

Namespace: DevExpress.XtraEditors

Assembly: DevExpress.XtraEditors.v19.1.dll

Declaration

[Browsable(false)]
public string ErrorText { get; set; }

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.

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the ErrorText property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also