如何在文本框中固定我的文本长度 [英] how to fix my text length in text box
本文介绍了如何在文本框中固定我的文本长度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好!
如何在文本框中固定我的文本长度,然后忽略一个以上的空格
我使用trim()函数
但仍然.....
hi to all!
how to fix my text length in textbox and ignore more then one space
i use the trim() function
but still .....
推荐答案
对于固定长度,您可以设置TextBox.MaxLength [ TextBox.TextChanged [^ ]事件并删除重复项-您可以使用string.Replace(",")来删除所有双精度项-将其写回时,将得到另一个TextChanged事件,因此请检查输入是否与设置新值之前的输出.
For fixed length, you can set the TextBox.MaxLength[^] property.
To prevent double spacing, handle the TextBox.TextChanged[^] event and remove duplicates - you can use string.Replace(" ", " ") which will remove all doubles - when you write it back, you will get another TextChanged event, so check if the input is the same as the output before setting the new value.
对于文本长度,您可以使用文本框的Maxlength属性
对于双倍间距,请尝试实现是否在textChanged事件中使用{}
for the text length u can use Maxlength property of the textbox
and for double spacing try to implement if {} in textChanged Event
这篇关于如何在文本框中固定我的文本长度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文