Rad Mask文本框:将“文本"更改为上方,并将光标置于文本的末尾. [英] Rad Mask TextBox: Change Text to upper and position cursor at end of the text.
本文介绍了Rad Mask文本框:将“文本"更改为上方,并将光标置于文本的末尾.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有Rad Mask文本框和一个按钮.因此,用户可以在文本框中输入任何大小写.单击按钮时,我正在基于文本和事件获取一些记录,必须将文本更改为上半部,修剪并定位插入符号的末端.
I have Rad Mask TextBox and a button. So user can enter any case into the text box. when button is clicked, I am fetching some record based on text and event I have to change the text to upper, trim and position the caret to end.
我注意到,如果输入了大写字母,我会得到所有方案的内容,但是当输入小写字母时,光标的位置会指向开始.
I noticed, if upper case is entered, I get all the scenario's but when lower case is entered the postion of cursor is pointed to beginning.
这就是我尝试过的.
txtSearch.MaskedText = txtSearch.MaskedText.ToUpperInvariant().Trim();
txtSearch.SelectionOnFocus = SelectionOnFocus.CaretToEnd;
非常感谢您的帮助.
推荐答案
SelectionStart解决了该要求.
SelectionStart has solved the requirement.
Dispatcher.BeginInvoke(() =>
{
if (txtSearch.MaskedText != null)
{
txtSearch.MaskedText = txtSearch.MaskedText.ToUpper();
txtSearch.SelectionStart = txtSearch.MaskedText.Length;
txtSearch.Focus();
}
});
这篇关于Rad Mask文本框:将“文本"更改为上方,并将光标置于文本的末尾.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文