如何强制使用电话号码格式 [英] How do I force phone number format

查看:78
本文介绍了如何强制使用电话号码格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的Windows窗体中,我有一个区域供用户输入电话号码(美国)。

有很多不同的方式来显示这些信息...

(###)### - ####

###。###。####

# - ### - ## # - #### x ###(其中x是扩展名)



无论用户输入什么类型或粘贴,我如何强制输入格式为'### - ### - ####'?如果有扩展名,可以在格式'x ###'中添加,但不是必需的。

解决方案

你可以使用一个或另一个<$对于WPF,c $ c> MaskedTextBox 。例如,

https://wpftoolkit.codeplex.com/wikipage?title = MaskedTextBox& referTitle = Home [ ^ ],

http://www.c-sharpcorner .com / UploadFile / mahesh / wpf-maskedtextbox-control [ ^ ],

用于数值的WPF可屏蔽文本框 [ ^ ]。





-SA

In my windows form I have an area for the user to enter a phone number (American).
There are many different way to display this info...
(###) ###-####
###.###.####
#-###-###-#### x### (where x is an extension)

How can I force the input, no matter what the user types or pastes, to be in the format of '###-###-####'? If there is an extension it could be added at the end in format 'x###', but is not necessary.

解决方案

You can use one or another MaskedTextBox for WPF. For example,
https://wpftoolkit.codeplex.com/wikipage?title=MaskedTextBox&referringTitle=Home[^],
http://www.c-sharpcorner.com/UploadFile/mahesh/wpf-maskedtextbox-control[^],
WPF Maskable TextBox for Numeric Values[^].


—SA


这篇关于如何强制使用电话号码格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆