1、如何使没有选择日期的DateTimePicker控件为空文本?(How to make the DateTimePicker show empty text if no date is selected?)
dateTimePicker1.CustomFormat = '';
dateTimePicker1.Format = DateTimePickerFormat.Custom;
2、如果选择日期的DateTimePicker控件返回当前日期
private void dateTimePicker1_CloseUp(object sender, EventArgs e)
{
this.dateTimePicker1.Format = DateTimePickerFormat.Long;
}
或者
private void dateTimePicker1_CloseUp(object sender, EventArgs e)
{
dateTimePicker1.CustomFormat = "ddd dd MMM yyyy";;
}
dateTimePicker1.CustomFormat = '';
dateTimePicker1.Format = DateTimePickerFormat.Custom;
2、如果选择日期的DateTimePicker控件返回当前日期
private void dateTimePicker1_CloseUp(object sender, EventArgs e)
{
this.dateTimePicker1.Format = DateTimePickerFormat.Long;
}
或者
private void dateTimePicker1_CloseUp(object sender, EventArgs e)
{
dateTimePicker1.CustomFormat = "ddd dd MMM yyyy";;
}