WPF: Specific input textboxes (for phone numbers and such)

邮差的信 提交于 2020-01-04 03:15:08

问题


I don't know what this is called, but I'm sure theres a name for this and it has been done multiple times.

I have some textboxes that ideally would only allow specific input, like a box for phone number, bank account numbers and stuff like that.
For instance, a phone number input should be in the following format: 000-000-0000 but I'd also like it to accept a number without an area code like : 000-0000

Now I have made a control derived from textbox that accepts only numeric input, but I have no idea how I would get the dashes to appear in the right spots without doing some fugly hacks in the TextChanged event.

I know this has probably been done to death, I tried to google but I didn't have the right words.


回答1:


You should use mask textboxes
there is some free open source mask textboxes

look here



来源:https://stackoverflow.com/questions/6320273/wpf-specific-input-textboxes-for-phone-numbers-and-such

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!