WPF用C#如何设置时间控件?? 项目需要,要求显示软件正常运行时间。要求如下:运行时获得当时运行时间,在结合现在时间,得到正常运行时间,并在textBox中显示。请高手指点。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 好像WPF中并没有System.Windows.Forms.Timer控件,但是可以使用System.Windows.Threading中的DispatcherTimer类DispatcherTimer dispatcherTimer = new System.Windows.Threading.DispatcherTimer(); dispatcherTimer.Tick += new EventHandler(dispatcherTimer_Tick); dispatcherTimer.Interval = new TimeSpan(0, 0, 1); dispatcherTimer.Start(); 你好,如何让时间在textBox中显示呢。 上面的问题解决了,直接采用三楼的方法就行。另外,如何控制dispatchertimer的开关呢?我用下面的方法怎么不行.private void button_click (object sender, routedEventarges e){ dispatchertimer wpftimer = new dispatchertimer(); wpftimer.Interval = new Timespan(0,0,1); wpftimer.Tick += new EventHandler(wpftimer_tick); if (wpftimer.IsEnabled == true) { wpftimer.Start(); } else { wpftimer.Stop(); }}void wpftimer_tick(object sender, EventArgs e){ txtTime.Text = DateTime.Now.ToLongTimeString();}想通过上述方法实现点击按钮控制dispatchertimer的开与关之间切换。不知道问题出在什么地方? 你好没有学过C#不过我怎么看着,你写得有点那个不正确啊,要通过点击按钮实现时间的走与停的话就不要在这个void 中写关于时间其它方法 怎样使用WPF的时间控件选取时间呢?、 一直报Image img = Image.FromStream(ms);参数无效,这要怎么改??? 系统分辨率和窗体大小 如何提取图片的特征? 求助:关于ASPxgridview 文件“bin\Debug\PMS.exe”正由另一进程使用 c# 线程同步 写锁 为什么我用Deflate和GZip压缩却越压越大? 求教:用dataset查找文本框的数据在数据库是否存在 ListView 的刷新问题 有共同基类的类为什么不一定有共同的接口 C# socket 服务器问题 StringType.StrCmp是做什么意思?
dispatcherTimer.Tick += new EventHandler(dispatcherTimer_Tick);
dispatcherTimer.Interval = new TimeSpan(0, 0, 1);
dispatcherTimer.Start();
{ dispatchertimer wpftimer = new dispatchertimer();
wpftimer.Interval = new Timespan(0,0,1);
wpftimer.Tick += new EventHandler(wpftimer_tick);
if (wpftimer.IsEnabled == true)
{
wpftimer.Start();
}
else
{
wpftimer.Stop();
}
}void wpftimer_tick(object sender, EventArgs e)
{
txtTime.Text = DateTime.Now.ToLongTimeString();
}想通过上述方法实现点击按钮控制dispatchertimer的开与关之间切换。不知道问题出在什么地方?