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:
- Place the ErrorProvider component onto a form.
- Change its Icon property to the necessary icon
- 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 BasicPrivate 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