使用当前日期和时间填充掩码文本框 [英] fill a mask textbox with current date and time
本文介绍了使用当前日期和时间填充掩码文本框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是这个编程世界的学生
我正在做一个csharp项目,但我面临的问题是填充当前日期的掩码文本框。和当前时间的另一个面具文本框
喜欢
25/12/2012和
wit
10:10 AM
i已经做了这个,但是有些错误即将来临。
i am a student to this programming world
I am doing a csharp project but the problem here i am facing is mask textbox filling with current date. and another mask textbox with current time
like
25/12/2012 and
wit
10:10 AM
i have made this but some error is coming.
maskedTextBox1.Text = DateTime.Now.ToString();
引用:
但是这样填充
12/62 / 012_
如何制作这个作为
06/12/2012
but it is filling like this
12/62/012_
how to make this as
06/12/2012
推荐答案
试试这个:
Try this:
maskedTextBox1.Text = string.Format("{0:dd/MM/yyyy}", DateTime.Now);
maskedTextBox1.Text = Convert.ToDateTime(DateTime.Now).ToString();
在窗体中右键单击属性
自定义格式yyyy / MM / dd
in the form right click properties
custom format yyyy/MM/dd
这篇关于使用当前日期和时间填充掩码文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文