How to: Restrict Values Being Entered in Editors
The following sample code prohibits values greater than 100 being entered into the spin editor. The RepositoryItem.Validating event is handled to check the entered value’s validity. The BaseEdit.InvalidValue event is handled to display an exception hint if an invalid value has been entered.
using System.ComponentModel;
using DevExpress.XtraEditors.Controls;
private void spinEdit1_Validating(object sender, CancelEventArgs e) {
if((sender as SpinEdit).Value >= 100)
e.Cancel = true;
}
private void spinEdit1_InvalidValue(object sender, InvalidValueExceptionEventArgs e) {
e.ErrorText = "The value should be less than 100";
}