Click here to Skip to main content
15,893,663 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi,
How can i enter dateformat in textbox field.I can enter only dateformat like yyyymmdd in textbox.
Can any one help me please.
Posted

You can use
1. MaskedTextBox[^]
or
2. DateTimePicker.CustomFormat Property[^] for formatting the textbox.
 
Share this answer
 
Comments
Aarti Meswania 9-May-13 2:23am    
5+! :)
Thanks a lot @Aarti Meswania... :)
Aarti Meswania 9-May-13 2:26am    
Welcome! :)
 
Share this answer
 
v2
Comments
pravallika tumuluri 9-May-13 2:25am    
Thanks for reply,
But i can write this validation in keypress event.By using these i can able to enter chars also.
I can enter dateformat only.
For those formats, please see:
http://msdn.microsoft.com/en-us/library/az4se3k1.aspx[^],
http://msdn.microsoft.com/en-us/library/8kb3ddd4.aspx[^].

However, I'm not sure writing date/time in a text box is a good idea. Why? Having the users to type it can drive them crazy, and validation of the result, too. Isn't the DateTimePicker control much better? Please see:
http://msdn.microsoft.com/en-us/library/system.windows.forms.datetimepicker.aspx[^].

—SA
 
Share this answer
 

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