This is a sample code:
这是一个示例代码:
ButtonEdit be = new ButtonEdit()
{
DisplayFormatString = MyDisplayFrm,
MaskType = MaskType.RegEx,
Mask = "[-+]?([0-9]*[,.])?[0-9]+([eE][-+]?[0-9]+)?",
ValidateOnTextInput = false
};
Binding bindingValue = new Binding() { Source = PropItem, Path = new PropertyPath("Value"), Mode = BindingMode.TwoWay };
BindingOperations.SetBinding(be, ButtonEdit.EditValueProperty, bindingValue);
be.SetValue(Grid.ColumnProperty, 0);
be.Validate += be_Validate;
void be_Validate(object sender, ValidationEventArgs e)
{
if ((Convert.ToDouble(e.Value) <= MaxVal) && (Convert.ToDouble(e.Value) >= MinVal)) return;
MessageBoxResult mbr = MessageBox.Show("The value in not in the suggested range, do you want to continue?", "Min/Max Range validation", MessageBoxButton.YesNo);
if (mbr == MessageBoxResult.Yes)
{
return;
}
else
{
e.IsValid = false;
e.ErrorType = DevExpress.XtraEditors.DXErrorProvider.ErrorType.Warning;
e.ErrorContent = "Value is not in the suggested range. Please correct.";
}
}
ButtonEdit