C#中将dateTimePicker初始值设置为空
更新时间:2023年02月06日 10:47:38 作者:唄小白
本文主要介绍了C#中将dateTimePicker初始值设置为空,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
本文主要介绍了C#中将dateTimePicker初始值设置为空,具体如下:
//窗体初始化事件 private void Form1_Load(object sender, EventArgs e) { this.dateTimePicker1.Format = DateTimePickerFormat.Custom; this.dateTimePicker1.CustomFormat = " "; //" "引号中间必须有空格 //this.dateTimePicker1.Checked = false; } private void dateTimePicker1_ValueChanged(object sender, EventArgs e) { this.dateTimePicker1.Format = DateTimePickerFormat.Long; this.dateTimePicker1.CustomFormat = null; } //清空按钮事件 private void button1_Click(object sender, EventArgs e) { this.dateTimePicker1.Format = DateTimePickerFormat.Custom; this.dateTimePicker1.CustomFormat = " "; this.dateTimePicker1.Checked = false; } //读取按钮事件 private void button2_Click(object sender, EventArgs e) { if(dateTimePicker1.Text==" ") { this.textBox1.Text = "日期为空!"; } else { this.textBox1.Text = this.dateTimePicker1.Text; } }
到此这篇关于C#中将dateTimePicker初始值设置为空的文章就介绍到这了,更多相关C# dateTimePicker初始值为空内容请搜索脚本之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持脚本之家!
相关文章
C#模板方法模式(Template Method Pattern)实例教程
这篇文章主要介绍了C#模板方法模式(Template Method Pattern),以实例形式讲述了C#抽象类模板方法的用法,具有很高的实用价值,需要的朋友可以参考下2014-09-09Visual Studio中根据系统区分引用64位、32位DLL动态库文件的配置方法
这篇文章主要介绍了Visual Studio中根据系统区分引用64位、32位DLL动态库文件的配置方法,本文在VS2008中测试通过,其它VS版本可以参考下2014-09-09
最新评论