在C#上运行并显示时钟 [英] run and display of clock on C#

查看:362
本文介绍了在C#上运行并显示时钟的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

hi
我怎样才能在C#上使用datetimepicker来显示项目的每一秒钟,例如日期和PC每秒都会改变?

hi how can i use datetimepicker on C# for display every seconds of time on project like date and of PC that changes every seconds?

推荐答案

DateTimePicker不用于显示日期和时间 - 它意味着用户输入信息。



如果要显示当前日期和时间,以便它会每秒更改一次:

0)在表单上添加标签

1)在表单中添加一个计时器。

2)设置它间隔属性为500 - 即每半秒。

3)为其Tick事件设置处理程序

4)在处理程序中,将Label.Text属性设置为当前时间:

A DateTimePicker isn't meant for display of date and time - it's meant for the user to enter information.

If you want to display the current date and time so that it changes every second:
0) Add a Label to your form
1) Add a Timer to your form.
2) Set it's Interval property to 500 - that's every half a second.
3) Set up a handler for its Tick event
4) In the handler, set the Label.Text property to the current time:
myLabel.Text = DateTime.Now.ToString();


我应该有一个Timer和一个DateTimePicker。在计时器刻度中,必须写:

i should have a Timer and a DateTimePicker. in timer tick, must write:
private void timer1_Tick(object sender, EventArgs e)
        {
            dateTimePicker1.ResetText();
        }



并选择计时器间隔= 999(由于运行时间延迟)或1000


and select timer interval=999 (because of run time delay) or 1000


这篇关于在C#上运行并显示时钟的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆