隐藏PromptChar对.NET的MaskedTextBox中 [英] Hiding the PromptChar for .NET's MaskedTextBox

查看:769
本文介绍了隐藏PromptChar对.NET的MaskedTextBox中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法使用MaskedTextBox中不显示的PromptChar?我想指定一个面具来验证输入,但我不希望任何提示字符在编辑模式下占用空间。

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.

设置PromptChar来()不起作用。它设置为零角空格(\ u200B)似乎工作,但奇怪的事情发生时,面具达到一定长度(13个字符似乎是一个神奇的数字)。或将只推出自己这是最好的吗?

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?

推荐答案

这是一个老问题,但希望这将帮助其他人在同一个问题绊脚石。 对我来说,在.NET 2.0及以上,该场所,HidePrompt,设置为true,隐藏的提示文字,直到你点击的领域。因此,首先设置你的提示字符空格,然后更改InsertKeyMode到插入,然后设置HidePrompt为True。改变提示字符到一个空间prevents从当用户点击它被看见的提示,hideprompt隐藏它在一般情况下,并插入模式会允许它们的用户到外地的开始而不是单击中间提示字符字段。

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.

这篇关于隐藏PromptChar对.NET的MaskedTextBox中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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