C#wpf工具箱中是否有用于设置时间或日期的控件? [英] Is there a control in toolbox of C# wpf for set time or date?
本文介绍了C#wpf工具箱中是否有用于设置时间或日期的控件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我想要一个类似Windows的日期和时间设置"对话框的控件,里面有一个文本框,里面有小箭头,我们也可以使用键盘上的up_down箭头设置时间或日期.
如果清楚,请描述此问题.
谢谢您.
Hi everybody,
I want have a control like "Date and Time Settings" dialog of windows that there are a textbox and inside it small arrows, also we can set time or date with up_down arrow on keyboard.
If clear this describe please help me for the issue.
Thanks in advanced.
推荐答案
可能不是,不是GAC中.NET附带的内容.看一看: http://datetimepickerwpf.codeplex.com/ [
Probably not, not what comes with .NET in the GAC. Look at this one: http://datetimepickerwpf.codeplex.com/[^].
—SA
您可以使用我的微调器/上下控件中的几个来创建这样的控件:
参见从TextBox继承的数字上/下文本框 [^ ]
您可以执行上述操作,也可以修改代码以执行所需的操作.
You can use several of my spinner/up-down control to create such a control:
see Numeric Up/Down Textbox that Inherits from TextBox[^]
YOu can either do the above, or modify the code to do what you want.
对于GeT时间
For GeT Time
System.DateTime time = System.DateTime.Now;
int hour = time.Hour;
int minute = time.Minute;
int second = time.Second;
int day = time.Day;
int month = time.Month;
int year = time.Year;
string dayofweek = time.ToString("dddd");
textBox1.Text = hour.ToString();
textBox2.Text = minute.ToString();
textBox3.Text = second.ToString();
textBox4.Text = day.ToString();
textBox5.Text = month.ToString();
textBox6.Text = year.ToString();
textBox13.Text = dayofweek.ToString();
对于SET时间
For SeT Time
SystemTime newtime = new SystemTime();
{
string year = textBox12.Text;
ushort yearOut = Convert.ToUInt16(year);
newtime.Year = (ushort)yearOut;
string month = textBox11.Text;
ushort monthOut = Convert.ToUInt16(month);
newtime.Month = (ushort)monthOut;
string day = textBox10.Text;
ushort dayOut = Convert.ToUInt16(day);
newtime.Day = (ushort)dayOut;
string hour = textBox7.Text;
ushort hourOut = Convert.ToUInt16(hour);
newtime.Hour = (ushort)hourOut;
string minute = textBox8.Text;
ushort minuteOut = Convert.ToUInt16(minute);
newtime.Minute = (ushort)minuteOut;
string second = textBox9.Text;
ushort secondOut = Convert.ToUInt16(second);
newtime.Second = (ushort)secondOut;
}
Win32SetSystemTime(ref newtime);
希望代码能对您有所帮助
I wish that code help you
这篇关于C#wpf工具箱中是否有用于设置时间或日期的控件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文