创建自定义验证提供程序devexpress

时间:2014-03-28 07:33:00

标签: c# winforms devexpress

我正在使用devexpress 13.1,我喜欢为文本框创建自定义验证提供程序

我尝试使用此代码

DevExpress.XtraEditors.DXErrorProvider.ConditionValidationRule containsValidationRule = new DevExpress.XtraEditors.DXErrorProvider.ConditionValidationRule();
containsValidationRule.ConditionOperator = DevExpress.XtraEditors.DXErrorProvider.ConditionOperator.GreaterOrEqual;
containsValidationRule.Value1 = '0';
containsValidationRule.ErrorText = "Veuillez saisir un valeur supérieur a zéro";
containsValidationRule.ErrorType = ErrorType.Warning;

CompareAgainstControlValidationRule compValidationRule = new CompareAgainstControlValidationRule();
compValidationRule.Control = txtStockMax;
compValidationRule.CompareControlOperator = CompareControlOperator.LessOrEqual;
compValidationRule.ErrorText = "Veuillez saisir un valeur inférieur au stock max";
compValidationRule.CaseSensitive = true;

dxValidationProvider1.SetValidationRule(txtStockMin, containsValidationRule);
dxValidationProvider1.SetValidationRule(txtStockMin, compValidationRule);

我正在寻找的是txtStockMin {0} {1}}而greaterOrEqual txtStockMin lessOrEqual <{1}}

1 个答案:

答案 0 :(得分:0)

请查看DXValidationProvider帮助主题。本主题还包含有关如何创建任何自定义验证规则的明确代码示例。