Date Time Picker form中有两个日期一个是记录日期,另一个是交款日期当没有交款时,记录日期需要为空白两个日期使用DATE TIME PICKER请问如何另此控件空 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 System.Windows.Forms.DateTimePicker dtp; dtp.ShowCheckBox = true; dtp.Checked = false; checkbox没选中时是不保存数据的 MessageBox.Show(this.dtpdate.Value.ToString(),"test");无论是否被选中,都show出日期 不管怎样,它的TEXT属性不可能为空,它的值与一个MONTH CALENDAR绑定了。要设置记录日期为空,可以在保存数据是设置为空就行。如果非要实现为空的效果,可以用一个TEXTBOX,它的KEYPRESS事件中e.handled=true即保证不让用户手动输入private void textBox1_KeyPress(object sender, KeyPressEventArgs e) { e.Handled = true; } private void textBox1_MouseClick(object sender, MouseEventArgs e) { if (this.dateTimePicker1.Visible == false) { this.dateTimePicker1.Visible = true; } } private void textBox1_MouseDown(object sender, MouseEventArgs e) { if (this.dateTimePicker1.Visible == false) { this.dateTimePicker1.Visible = true; } } private void textBox1_MouseEnter(object sender, EventArgs e) { if (this.dateTimePicker1.Visible == false) { this.dateTimePicker1.Visible = true; } } //控制让其隐藏 private void dateTimePicker1_MouseLeave(object sender, EventArgs e) { if (this.dateTimePicker1.Visible == true) { this.dateTimePicker1.Visible = false; } } //赋值 private void dateTimePicker1_ValueChanged(object sender, EventArgs e) { this.textBox1.Text = this.dateTimePicker1.Text; }当然还有其他的方法了,不赘述 這個方法確實能解實現,但是.NET是否沒有直接解決辦法呢? 下边的代码可以实现你要的功能,让dateTimePicker1控件显示为空,下边代码的意思就是:让控件使用自定义的格式显示。 dateTimePicker1.Format = DateTimePickerFormat.Custom;dateTimePicker1.CustomFormat = " ";希望对你有用! MessageBox.show(dateTimePicker1.Value,"test")是有数据显示的 变相的实现一下,不需要显示的时候隐藏dtp,放一个空的文本框在上面好了。 需要另外的一个控件来控制是否保存,再说了,可以从业务上处理啊,没有较宽日期的就那个日期添加null或者不添加啊 Session获取登录用户数量及具体值 关于异步调用问题,急!!!! 如何在窗体A中捕获窗体B的关闭事件 这个C#关机命令有什么错啊? C#中如何制作多窗口程序?谢谢。 一个关于表格的简单问题 求c#编写winform程序实现报表(表格、柱状图)功能源程序例子 谢谢 高分求购Grid注册码. C#.net 接口问题 新手求助。请教如何解读这段程序。谢谢。 DataGridView取单元格值 计算并赋值的问题!!
dtp.ShowCheckBox = true;
dtp.Checked = false;
无论是否被选中,都show出日期
private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
e.Handled = true;
} private void textBox1_MouseClick(object sender, MouseEventArgs e)
{
if (this.dateTimePicker1.Visible == false)
{
this.dateTimePicker1.Visible = true;
}
} private void textBox1_MouseDown(object sender, MouseEventArgs e)
{
if (this.dateTimePicker1.Visible == false)
{
this.dateTimePicker1.Visible = true;
}
} private void textBox1_MouseEnter(object sender, EventArgs e)
{
if (this.dateTimePicker1.Visible == false)
{
this.dateTimePicker1.Visible = true;
}
}
//控制让其隐藏
private void dateTimePicker1_MouseLeave(object sender, EventArgs e)
{
if (this.dateTimePicker1.Visible == true)
{
this.dateTimePicker1.Visible = false;
}
}
//赋值
private void dateTimePicker1_ValueChanged(object sender, EventArgs e)
{
this.textBox1.Text = this.dateTimePicker1.Text;
}
当然还有其他的方法了,不赘述
dateTimePicker1.CustomFormat = " ";希望对你有用!
是有数据显示的
再说了,可以从业务上处理啊,没有较宽日期的就那个日期添加null或者不添加啊