C# DateTimePicker控件设置空时间

 

 //在DateTime旁边添加一个清空按钮.

        private void btnClearRegTime_Click(object sender, EventArgs e)
        {
            MessageBox.Show("Text:" + dtpRegTime.Text + "\nValue:" + dtpRegTime.Value.ToString());
            dtpRegTime.CustomFormat = "   ";
            MessageBox.Show("Text:" + dtpRegTime.Text + "\nValue:"+dtpRegTime.Value.ToString());
        }

 

dtpRegTime.CustomFormat = "   ";的作用是让dtp.Text为"" ,但dtp.value其实还是时间值。录入数据库的事后要使用dtp.text.

posted on 2012-06-18 10:47  imihiro  阅读(2519)  评论(0编辑  收藏  举报