MaskedTextBox中最小/最大长度 [英] MaskedTextBox Minimum/Maximum Lengths

查看:463
本文介绍了MaskedTextBox中最小/最大长度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个蒙面文本框与需要有一个最小/最大长度为他们设置。当这些条件满足一个按钮变为启用。

我在想处理TextChanged事件,以确定所输入的文本的长度,并设置按钮允许值。

有没有更好的方法?

  btnOK.Enabled = txtDataEntry.Text.Length> = MinDataLength和放大器;&安培; txtDataEntry.Text.Length< = MaxDataLength;
 

解决方案

哪种方法能比你的建议是什么就更简单了?

  myTextBox.Textchanged + =(S,O)=> {myButton.Enabled = myTextBox.Length == 10; };
 

I have a masked textbox with the need to have a min/max length set on them. When these conditions are met a button becomes enabled.

I was thinking of handling the TextChanged event to determine the length of the entered text and set the buttons enabled value.

Is there a better approach?

 btnOK.Enabled = txtDataEntry.Text.Length >= MinDataLength && txtDataEntry.Text.Length <= MaxDataLength;

解决方案

Which approach could be even simpler than what you are suggesting?

myTextBox.Textchanged+=(s,o)=>{ myButton.Enabled = myTextBox.Length==10; };

这篇关于MaskedTextBox中最小/最大长度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆