網站首頁 編程語言 正文
本文主要介紹了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;
}
}
原文鏈接:https://blog.csdn.net/qq_43335448/article/details/127053797
相關推薦
- 2022-08-02 Python自動化測試之異常處理機制實例詳解_python
- 2022-11-20 C#?崩潰異常中研究頁堆布局的詳細過程_C#教程
- 2023-07-05 React 簡單實現 v-if和v-show的元素控制效果
- 2022-07-04 圖神經網絡GNN算法基本原理詳解_python
- 2022-11-08 詳解Python中數據處理的方法總結及實現_python
- 2022-12-10 C++中如何將數據保存為CSV文件_C 語言
- 2022-04-21 python的變量和運算符你都知道多少_python
- 2022-11-18 如何使用Python生成Hilbert矩陣_python
- 最近更新
-
- window11 系統安裝 yarn
- 超詳細win安裝深度學習環境2025年最新版(
- Linux 中運行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎操作-- 運算符,流程控制 Flo
- 1. Int 和Integer 的區別,Jav
- spring @retryable不生效的一種
- Spring Security之認證信息的處理
- Spring Security之認證過濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權
- redisson分布式鎖中waittime的設
- maven:解決release錯誤:Artif
- restTemplate使用總結
- Spring Security之安全異常處理
- MybatisPlus優雅實現加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務發現-Nac
- Spring Security之基于HttpR
- Redis 底層數據結構-簡單動態字符串(SD
- arthas操作spring被代理目標對象命令
- Spring中的單例模式應用詳解
- 聊聊消息隊列,發送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠程分支