Winform DateTimePicker控件自定义时间格式

Winform DateTimePicker控件自定义时间格式
this.dateTimePicker1.Format = DateTimePickerFormat.Custom;
this.dateTimePicker1.CustomFormat = "yyyy年MM月dd日";
// 创建的日期格式化字符串
//      yyyy-MM-dd HH:mm 24时制
//      yyyy-MM-dd hh:mm 12时制

// 取DateTimePicker控件时间
this.textBox1.Text = dateTimePicker1.Value;

// 设置DateTimePicker控件时间
this.dateTimePicker1.Value = DateTime.Now;


C# 社区推荐