开发者

C# custom mask for textbox

I know there is masked textbox component for C#, but what I need is to create masked text box which requires开发者_JAVA百科 entered text in format: LLL/LLL but when I enter such mask into Mask property in preview and mask I see separator "." but not "/" as I want to have. Any help? Thanks


The / character is the date separator character in the mask. What you'll actually get depends on your culture preferences. To get a literal / you'll have to escape it with a \. Like this:

        this.maskedTextBox1.Mask = @"LLL\/LLL";

Don't use the @ when you use the Properties window.


Thanks for this clue there is one more problem in maskedtextbox that is when the system short date changes the mask also changes for example..

Before

System date : d/M/yy  
Mask Format : __/__/__

After

System date : d-M-yy  
Mask Format : __-__-__ 

Using escape char hepled me.

Just add escape char in mask. For example:

textbox1.Mask = 00/\00/\00
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜