[英]c# how to modify the control's property
I get a control from customers. 我得到了客户的控制。 just a dll file.
只是一个dll文件。
it like a textbox. 它像一个文本框。 use user to input the value, now as called SUTextBox .
使用用户输入值,现在称为SUTextBox 。
it have a property "IsemailValidation=true", then it can validate email address. 它具有属性“ IsemailValidation = true”,那么它可以验证电子邮件地址。
now ,I have a request like this. 现在,我有这样的要求。 if user input value ,then validate it ,
如果用户输入了值,则对其进行验证,
if user don't input value ,then don't validate ,just get empty data(this control cannot be empty if set IsemailValidation=true ). 如果用户不输入值,则不进行验证,仅获取空数据(如果设置IsemailValidation = true,则此控件不能为空)。
The key question is that,if I set IsemailValidation=true . 关键问题是,如果我设置IsemailValidation = true 。 this textbox cannot be empty.
此文本框不能为空。 and I want to it can be empty or have valid email address.
我希望它可以为空或具有有效的电子邮件地址。
Can I set the property somewhere dynamic? 我可以将属性设置为动态位置吗?
I bet your SUTextBox
should have some TextChanged
event and we can handle this event like this: 我敢打赌,您的
SUTextBox
应该有一些TextChanged
事件,我们可以像这样处理该事件:
sUTextBox1.TextChanged += (s,e) => {
bool validate = !(sUTextBox1.Text == "");
if(sUTextBox1.IsemailValidation!=validate)
sUTextBox1.IsemailValidation = validate;
};
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.