×
您的位置: 首页 > 编程笔记

MaskedTextBox中最小/最大长度(MaskedTextBox Minimum/Maximum Lengths)

DotNET Core 时间:2020-06-18  查看:748   收藏

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; };

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

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

有没有更好的方法?

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

解决方案

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

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

 

0% (0)
0% (0)