TextBox中的DateFormat [英] DateFormat in TextBox

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

问题描述



如何在textbox字段中输入dateformat。我只能在文本框中输入yyyymmdd等日期格式。

任何人都可以帮助我。

解决方案

您可以使用

1. MaskedTextBox [ ^ ]



2. DateTimePicker.CustomFormat Property [ ^ ] for格式化文本框。


您好

请尝试以下...



DateTime.TryParseExact方法(String,String [],IFormatProvider,DateTimeStyles,DateTime) [< a href =http://msdn.microsoft.com/en-us/library/h9b85w22.aspxtarget =_ blanktitle =New Window> ^ ]



C#DateTime.TryParse [ ^ ]



使用DateTime.TryParseExact轻松解析格式化字符串日期 [ ^ ]



Happy Coding

Sebastian


对于这些格式,请参阅:

http://msdn.microsoft.com/en-us/library/az4se3k1.aspx [ ^ ],

http:// msdn.microsoft.com/en-us/library/8kb3ddd4.aspx [ ^ ]。



但是,我不确定在文本框中写日期/时间是个好主意。为什么?让用户输入它可以让他们疯狂,并验证结果。是不是 DateTimePicker 控件要好得多?请参阅:

http://msdn.microsoft .com / zh-cn / library / system.windows.forms.datetimepicker.aspx [ ^ ]。



-SA

Hi,
How can i enter dateformat in textbox field.I can enter only dateformat like yyyymmdd in textbox.
Can any one help me please.

解决方案

You can use
1. MaskedTextBox[^]
or
2. DateTimePicker.CustomFormat Property[^] for formatting the textbox.


Hi
please try the following...

DateTime.TryParseExact Method (String, String[], IFormatProvider, DateTimeStyles, DateTime)[^]

C# DateTime.TryParse[^]

Use DateTime.TryParseExact to Easily Parse Formatted String Dates[^]

Happy Coding
Sebastian


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


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

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