網(wǎng)站首頁 編程語言 正文
本文主要介紹了C#中將dateTimePicker初始值設(shè)置為空,具體如下:
//窗體初始化事件
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;
}
}
原文鏈接:https://blog.csdn.net/qq_43335448/article/details/127053797
相關(guān)推薦
- 2022-04-17 sessionStorage與localStorage
- 2023-06-17 Queue隊列中join()與task_done()的關(guān)系及說明_python
- 2022-04-25 Python如何生成exe文件?用Pycharm一步步帶你學(xué)(超詳細、超貼心)_python
- 2022-09-15 C++關(guān)于/2和>>1的區(qū)別說明_C 語言
- 2022-01-20 出現(xiàn)SLF4J: Failed to load class “org.slf4j.impl.Stat
- 2022-07-02 element下拉框獲取選中的內(nèi)容
- 2022-08-01 Python+Selenium鍵盤鼠標(biāo)模擬事件操作詳解_python
- 2023-09-12 springboot將jar改成war
- 最近更新
-
- window11 系統(tǒng)安裝 yarn
- 超詳細win安裝深度學(xué)習(xí)環(huán)境2025年最新版(
- Linux 中運行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎(chǔ)操作-- 運算符,流程控制 Flo
- 1. Int 和Integer 的區(qū)別,Jav
- spring @retryable不生效的一種
- Spring Security之認證信息的處理
- Spring Security之認證過濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權(quán)
- redisson分布式鎖中waittime的設(shè)
- maven:解決release錯誤:Artif
- restTemplate使用總結(jié)
- Spring Security之安全異常處理
- MybatisPlus優(yōu)雅實現(xiàn)加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務(wù)發(fā)現(xiàn)-Nac
- Spring Security之基于HttpR
- Redis 底層數(shù)據(jù)結(jié)構(gòu)-簡單動態(tài)字符串(SD
- arthas操作spring被代理目標(biāo)對象命令
- Spring中的單例模式應(yīng)用詳解
- 聊聊消息隊列,發(fā)送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠程分支