日本免费高清视频-国产福利视频导航-黄色在线播放国产-天天操天天操天天操天天操|www.shdianci.com

學(xué)無先后,達者為師

網(wǎng)站首頁 編程語言 正文

C#中將dateTimePicker初始值設(shè)置為空_C#教程

作者:唄小白 ? 更新時間: 2023-04-07 編程語言

本文主要介紹了C#中將dateTimePicker初始值設(shè)置為空,具體如下:

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

欄目分類
最近更新