蒙版文本框光标的起始位置 [英] Masked Text Box Cursor Start Position
本文介绍了蒙版文本框光标的起始位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
HI,
我需要在美国文本的带掩码文本框中输入电话号码,例如以下格式
(999)-000-0000
这里的问题是,当被遮罩的文本框处于焦点状态时,光标会在("Symbol
但是我需要光标在("符号后开始
我为Mouse Click Event编写了一个代码,它可以正常工作,但对于键盘选项卡,它不是
我的示例代码是:
I Have requirement to enter the phone numbers in a masked text box for the US based numbers like in the below format
(999)-000-0000
Here the problem is when the masked text box is focused the cursor starts before "(" Symbol
But i need the cursor starts after "(" symbol
I wrote a code for Mouse Click Event and it works fine but for keyboard tab its not
My Sample Code is:
The Belowcode is working fine for Mouse click event
private void txtPhone_MouseClick(object sender, MouseEventArgs e)
{
txtPhone.SelectionStart = 1;
}
The Below Code is not working for Focus on Masked TextBox
private void txtPhone_Enter(object sender, EventArgs e)
{
txtPhone.SelectionStart = 1;
}
在此先感谢......
sudhakar
Thanks In Advance......
sudhakar
推荐答案
当您使用(999)000-0000"作为Mask选择MaskedTextBox时,是的,插入光标出现在左侧的左侧-括号.
但是,您会注意到:在您开始输入数字的那一刻,就在左括号后面输入了您所期望的数字.那么,这真的很重要吗?
如果您确实对这种非常小的行为感到不便,请使用"000-000-0000"之类的掩码,然后根据需要插入光标.
When you select the MaskedTextBox using "(999) 000-0000" as the Mask, yes, the insertion cursor appears left of the left-parenthesis.
But, you''ll notice: that the moment you start typing a number the number is entered, as you might expect, after the left-parenthesis. So, is this really a big deal ?
If you are really bothered by this very minor behavior, use a mask like "000 - 000 - 0000" and you can have the insertion cursor as you wish.
这篇关于蒙版文本框光标的起始位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文