Is there a way to use MaskedTextBox without displaying the PromptChar? I would like to specify a mask to validate input against, but I don't want any prompt characters to take up space during edit mode.
The reason for this is when I want to accept free text with a limited character set, all characters are optional alphanumerics. The problem I have is that when I select all text, even the prompt characters are selected.
Setting PromptChar to (" ") doesn't work. Setting it to Zero-width space (\u200B) seems to work, but weird things happen when the mask reaches a certain length (13 characters seems to be the magic number). Or would it be best to just roll my own?
This is an old question, but hopefully this will help others stumbling upon the same issue. For me on .net 2.0 and above there is the property, 'HidePrompt', setting this to true hides the prompt text, until you click on the field. So, first set your prompt character to a space " ", and then change the 'InsertKeyMode' to "Insert", and then set the 'HidePrompt' to True. Changing the prompt character to a space prevents the prompt from being seen when the user clicks on it, hideprompt hides it in general, and insert mode takes the user to the beginning of the field instead of allowing them to click in the middle of the prompt character field.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With