Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

How to: Supply Custom Error Icon for Editor

The following example shows how to supply a custom error icon via the DXErrorProvider.GetErrorIcon event. In this event, a custom icon (DXErrorProvider_CustomIcon) is provided when the error type is set to ErrorType.User1.

The result is illustrated below:

DXErrorProvider_GetErrorIcon_ex

using DevExpress.XtraEditors.DXErrorProvider;

DXErrorProvider.GetErrorIcon += new GetErrorIconEventHandler(DXErrorProvider_GetErrorIcon);

// Associate an error of the User1 error type with a buttonEdit1 control.
dxErrorProvider1.SetError(buttonEdit1, "Error", ErrorType.User1);

//...

Image icon = Image.FromFile(@"C:\arrow.png");
// Provide an error icon for the User1 error type.
void DXErrorProvider_GetErrorIcon(GetErrorIconEventArgs e) {
    if (e.ErrorType == ErrorType.User1) {
        e.ErrorIcon = icon;
    }
}