How to get text from Masked Text Box without the masked format

Posted by Anuraj on Monday, June 2, 2014

.Net .Net 3.0 / 3.5 .Net 4.0 Windows Forms

Today I saw some SO question asked about how to get values from Masked Textbox without the masked format. For those who don’t know what is masked textbox - Uses a mask to distinguish between proper and improper user input.

Masked Textbox - With Phone Number mask property

Here is the code snippet.

//Make sure user completed the entry.
if (txtPhone.MaskFull)
{
    txtPhone.TextMaskFormat = MaskFormat.ExcludePromptAndLiterals;
    MessageBox.Show(txtPhone.Text);
    txtPhone.TextMaskFormat = MaskFormat.IncludePromptAndLiterals;
}

Happy Coding :)


Similar Posts


Did you like this article? Share it with your friends

Facebook Twitter Google+ LinkedIn Reddit StumbleUpon



MVP
Subscribe
Archives


Copyright © 2017 - Anuraj P. Blog content licensed under the Creative Commons CC BY 2.5 | Unless otherwise stated or granted, code samples licensed under the MIT license. This is a personal blog. The opinions expressed here represent my own and not those of my employer. Hosted with ❤ by GitHub