如何从MaskedTextBox获取原始文本? [英] How to get raw text from MaskedTextBox?

查看:174
本文介绍了如何从MaskedTextBox获取原始文本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个MaskedTextBox带有此掩码(999)999 9999. 当用户输入数字时,文本属性会将其提供给我:

I have a MaskedTextBox with this mask (999) 999 9999. When user inputs a number the text property would give this to me :

(0881) 444 5445

但是我想将原始文本保存到数据库字段中,如下所示:08814445445. 我该怎么办?

But I want to save the raw text to database field like this: 08814445445. How can I do that?

推荐答案

基于我发现的内容

Based on what I found here you can set the TextMaskFormat-Property to MaskFormat.ExcludePromptAndLiterals. That should be you solution.

MaskFormat-枚举为MaskedTextBox保留一些选项".
他们是:

The MaskFormat-Enumeration holds some "options" for the MaskedTextBox.
They are:

  1. ExcludePromptAndLiterals仅返回用户输入的文本.
  2. IncludeLiterals返回用户输入的文本以及掩码中定义的所有文字字符.
  3. IncludePrompt返回用户输入的文本以及提示字符的任何实例.
  4. IncludePromptAndLiterals返回用户输入的文本以及掩码中定义的所有文字字符以及提示字符的所有实例.
  1. ExcludePromptAndLiterals Return only text input by the user.
  2. IncludeLiterals Return text input by the user as well as any literal characters defined in the mask.
  3. IncludePrompt Return text input by the user as well as any instances of the prompt character.
  4. IncludePromptAndLiterals Return text input by the user as well as any literal characters defined in the mask and any instances of the prompt character.

默认为 IncludeLiterals

这篇关于如何从MaskedTextBox获取原始文本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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