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;
}
}
到此這篇關(guān)于C#中將dateTimePicker初始值設置為空的文章就介紹到這了,更多相關(guān)C# dateTimePicker初始值為空內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
C#中DataTable實現(xiàn)行列轉(zhuǎn)換的方法
這篇文章主要介紹了C#中DataTable實現(xiàn)行列轉(zhuǎn)換的方法,實例分析了C#操作DataTable的相關(guān)技巧,非常具有實用價值,需要的朋友可以參考下2015-04-04
在Framework 4.0中:找出新增的方法與新增的類(一)
經(jīng)常看到有同學在討論Framework 4 的新特性,新方法,于是想寫個程序找出framework4.0中新增的方法和類2013-05-05

