设置属性:
Format=Custom
加载事件:ValueChanged
private void dtpStart_ValueChanged(object sender, EventArgs e)
{//日期默认为空
this.dtpStart.CustomFormat = null;
}
在_load事件中:
this.dtpStart.Format = DateTimePickerFormat.Custom;
this.dtpStart.CustomFormat = " ";//中间要有空格
Format=Custom
加载事件:ValueChanged
private void dtpStart_ValueChanged(object sender, EventArgs e)
{//日期默认为空
this.dtpStart.CustomFormat = null;
}
在_load事件中:
this.dtpStart.Format = DateTimePickerFormat.Custom;
this.dtpStart.CustomFormat = " ";//中间要有空格
本文详细介绍了如何在编程中设置日期格式为自定义,并在加载事件中进行初始化。通过设置 DateTimePicker 控件的 Format 和 CustomFormat 属性,实现日期显示和输入的自定义样式。
6224

被折叠的 条评论
为什么被折叠?



