C#中的datetimepicker控件 [英] datetimepicker control in c#
本文介绍了C#中的datetimepicker控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何从datetimepicker控件的日期中删除空格.
例如:-
假设日期是:2010年11月2日.
执行后就表明了这一点.
2010年11月2日.
我想删除2处的空格,或者我应该在那里包含0.
帮帮我.
在Windows应用程序中(c#.net3.0)
问候,
nagaraju
Hi,
how can i remove the space from date of the datetimepicker control.
ex:-
suppose the date is: 11/02/2010.
after executing it is showing that.
11/ 2/2010.
i want to remove the space at 2 or i should include 0 there.
help me.
in windows applications(c#.net3.0)
regards,
nagaraju
推荐答案
使用CustomFormat
字符串.
http://msdn.microsoft.com/en-us/library/system.windows.forms.datetimepicker.customformat.aspx [ ^ ]
似乎要删除空格可能并不容易,但是您可以使用以下格式的字符串在此处得到零:MM/dd/yyyy
Use aCustomFormat
string.
http://msdn.microsoft.com/en-us/library/system.windows.forms.datetimepicker.customformat.aspx[^]
It seems it may not be easy to remove the space, but you could get a zero there by using this format string:MM/dd/yyyy
示例(对于应该包括0并删除空格的示例)在2):
Example (for should include 0 & remove the space at 2):
label1.Text = dateTimePicker1.Value.ToString("MM/dd/yyyy");
label1.Text += "\n" + dateTimePicker1.Value.Month + "/" + dateTimePicker1.Value.Day + "/" + dateTimePicker1.Value.Year;
这篇关于C#中的datetimepicker控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文