MaskedTextBox中最小/最大长度长度、最小、最大、MaskedTextBox

由网友(无梦旅人)分享简介:我有一个蒙面文本框与需要有一个最小/最大长度为他们设置。当这些条件满足一个按钮变为启用。我在想处理TextChanged事件,以确定所输入的文本的长度,并设置按钮允许值。有没有更好的方法?btnOK.Enabled = txtDataEntry.Text.Length> = MinDataLength和放大器;&...

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

我在想处理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; };

阅读全文

相关推荐

最新文章