Click here to Skip to main content
15,886,519 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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
Posted
Updated 26-Apr-12 18:28pm
v2

1 solution

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/[^]
 
Share this answer
 
Comments
Sakshi Smriti 27-Apr-12 1:23am    
This is not related to validation, it is the display of time e.g. if user enters valid time 14:1 then it is changed to 14:01 which is perfect, however after a while it changes to 14:1. It should ideally remain as 14:01
Deepak_Sharma_ 27-Apr-12 1:32am    
Have you set Mask property of the MaskedTextBox?
Sakshi Smriti 27-Apr-12 3:21am    
Yes it is set to H:mm.

The only issue is that it trunctaes leading zero in hours and minutes

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900