用于显示时间的带遮罩的文本框不起作用 [英] Masked text box used to show time does not work

查看:151
本文介绍了用于显示时间的带遮罩的文本框不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我在winforms(.net 3.5,C#)中使用带遮罩的文本框来显示用户以23:59格式输入时间的时间.

当用户输入诸如1:12或14:8之类的东西时,它会正常工作,它将根据需要更改为01:12和14:08,但是一秒钟后,它将再次更改为1:12和14:8 .它会截断前导零.

我做了很多尝试,并找到了在文本框数据绑定的高级部分中设置自定义格式的解决方案.文本框未绑定,因此我无法设置此选项.

我使用的面罩是H:mm.

在这方面的任何帮助将是非常可观的.

谢谢.

问候,
Sakshi

Hi,

I am using a masked text box in winforms (.net 3.5,C#) to show time in which user enters the time in the format 23:59.

It is working fine excpet when the user enter something like 1:12, or 14:8 it will change to 01:12 and 14:08 which is as required, however after a second it again changes to 1:12 and 14:8. It truncates the leading zeros.

I tried a lot and got a solution to set the custom format in the advanced section of the text box data binding. the text box in not bind so I cannot set this option.

The mask I am using is H:mm.

Any help in this regard will be highly appreciable.

Thanks.

Regards,
Sakshi

推荐答案



您必须验证在MaskedTextBox中输入的时间格式:
http://social.msdn.microsoft.com /Forums/zh-CN/vbgeneral/thread/d6b02bd5-c773-4f4d-9601-f08c2e1668d7/ [
Hi,

You have to validate format of time entered in the MaskedTextBox:
http://social.msdn.microsoft.com/Forums/en-US/vbgeneral/thread/d6b02bd5-c773-4f4d-9601-f08c2e1668d7/[^]


这篇关于用于显示时间的带遮罩的文本框不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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