2010-02-18 77 views
1

任何人都可以指导我如何设置VS日期时间选择器的日期格式使用c#如何在Windows窗体日期时间选择器中设置日期格式?

我想设置格式为2010年1月18日至18/01/10。

+0

显然,一个错字:你会希望将其设置为18/01/10,不18/01/01 :-) – 2010-02-18 04:56:25

+0

我认为你的意思是Windows窗体日期时间选择器?因为Visual Studio和C#都没有日期时间选择器。 – 2010-02-18 04:56:26

回答

1

更改格式定制自定义格式DD/MM/YY

看一看

Format属性设置控件的DateTimePickerFormat的 。默认日期格式为 DateTimePickerFormat.Long。如果 格式属性设置为 DateTimePickerFormat.Custom,您可以通过 创建您自己的格式样式设置CustomFormat属性和 构建自定义格式字符串。

0

事情是这样的:

dateTimePicker.Format = DateTimePickerFormat.Custom; 
dateTimePicker.CustomFormat = "dd/MM/yy"; 

正确读取的问题后编辑:P

0
var mytest = (dateTimePicker1.Value.ToShortDateString()).Replace("hh",string.Empty).Replace("mm", string.Empty).Replace("ss", string.Empty); 
cmd.Parameters.AddWithValue("@DOB",mytest); 
相关问题