如何在Winform中将日期时间选择器格式设置为仅月份日期和年份? [英] how to set date time picker format as only month date and year in winform?

查看:396
本文介绍了如何在Winform中将日期时间选择器格式设置为仅月份日期和年份?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

hi(使用winform默认日期时间选择器格式)是"Monday .july 29.2012"

那么如何将其更改为2012年7月9日这种格式?

有人可以帮我吗?
谢谢

hi in winform default date time picker format is "Monday .july 29.2012"

so how can i chnage this to 7/09/2012 this format?

can any one help me?
thanks

推荐答案

使用 ^ ]属性...

Use the DateTimePicker.Format[^] property...

myDateTimePicker.Format = DateTimePickerFormat.Custom;
myDateTimePicker.CustomFormat = "dd/MM/yyyy";




[edit]添加了示例-OriginalGriff [/edit]




[edit]Added example - OriginalGriff[/edit]


使用CustomFormat属性并根据需要定义格式.
Use CustomFormat property and define format as per your need.
public void SetMyCustomFormat()
{
   // Set the Format type and the CustomFormat string.
   dateTimePicker1.Format = DateTimePickerFormat.Custom;
   dateTimePicker1.CustomFormat = "dd/MM/yyyy";
}


参考: MSDN:DateTimePicker.CustomFormat属性 [ ^ ]


Refer: MSDN: DateTimePicker.CustomFormat Property [^]


这篇关于如何在Winform中将日期时间选择器格式设置为仅月份日期和年份?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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