KB Article A2840
Visible to All Users

How to display a custom error icon when an end-user enters invalid data into an editor

Description:
When an end-user inputs invalid data into a cell within a XtraGrid control, it will display a red icon to the left of the editor. Is there anyway I can change that icon?

Answer:
Yes, you can achieve this task using the windows ErrorProvider component. To achieve this task you should:

  1. Place the ErrorProvider component onto a form.
  2. Change its Icon property to the necessary icon
  3. Handle the GridView’s InvalidValueException event as shown below:
C#
private void gridView1_InvalidValueException(object sender, DevExpress.XtraEditors.Controls.InvalidValueExceptionEventArgs e) { e.ExceptionMode = DevExpress.XtraEditors.Controls.ExceptionMode.NoAction; errorProvider1.SetError(gridView1.ActiveEditor, <error text>); }
Visual Basic
Private Sub GridView1_InvalidValueException(ByVal sender As Object, ByVal e As DevExpress.XtraEditors.Controls.InvalidValueExceptionEventArgs) Handles GridView1.InvalidValueException e.ExceptionMode = DevExpress.XtraEditors.Controls.ExceptionMode.NoAction ErrorProvider1.SetError(GridView1, <error text>); End Sub

See Also:
How to Validate Changes Made to a Grid Cell

Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.