阅读背景:

为什么会调用两次textedit验证处理程序?

来源:互联网 

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



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: