Welcome to Dream.In.Code
Getting C# Help is Easy!

Join 109,295 C# Programmers for FREE! Ask your question and get quick answers from experts. There are 1,216 online right now! We've got more than 500 tutorials and 2,000 snippets. Join and find out why Dream.In.Code is the #1 programming help community on the internet! Registration is fast and FREE... Join Now!



win application form displays the current time

 
Reply to this topicStart new topic

win application form displays the current time

hudacskoa
post 5 Aug, 2008 - 06:05 PM
Post #1


New D.I.C Head

*
Joined: 5 Aug, 2008
Posts: 2

hi,

i'd like to display the actual time on my c# form.
i can read now just the system time during an event handling eg pushing a refresh button.
it's not very user friendly:|

which other method can i use to display a continuously ticking time on my form?

thanks

attila
User is offlineProfile CardPM

Go to the top of the page


no2pencil
post 5 Aug, 2008 - 07:53 PM
Post #2


Wet D.I.C.

Group Icon
Joined: 10 May, 2007
Posts: 4,939



Thanked 27 times

Dream Kudos: 2325

Expert In: Goofing Off

My Contributions


QUOTE(hudacskoa @ 5 Aug, 2008 - 09:05 PM) *

i'd like to display the actual time on my c# form.

Then why are we posting this in C/C++?

** Moved **
User is offlineProfile CardPM

Go to the top of the page

jayman9
post 5 Aug, 2008 - 08:01 PM
Post #3


Student of Life

Group Icon
Joined: 26 Dec, 2005
Posts: 6,322



Thanked 22 times

Dream Kudos: 500

Expert In: C#, VB.NET, Java

My Contributions


Try using a Timer control while updating labels that will display the numbers.

Dream.In.Code has a policy by which we prefer to see a good faith effort on your part before providing source code for homework assignments. Please post the code you have written in an effort to resolve the problem, and our members would be happy to provide some guidance. Be sure to include a description of any errors you are encountering as well.

Please post like this:

Thank you for helping us helping you.
User is online!Profile CardPM

Go to the top of the page

zakary
post 6 Aug, 2008 - 05:49 AM
Post #4


D.I.C Regular

Group Icon
Joined: 15 Feb, 2005
Posts: 372



Thanked 4 times

Dream Kudos: 175
My Contributions


here is a tutorial on times and threading
http://www.dreamincode.net/forums/showtopic45904.htm
User is offlineProfile CardPM

Go to the top of the page

eclipsed4utoo
post 6 Aug, 2008 - 06:00 AM
Post #5


D.I.C Head

**
Joined: 21 Mar, 2008
Posts: 107



Thanked 6 times
My Contributions


QUOTE(zakary @ 6 Aug, 2008 - 08:49 AM) *

here is a tutorial on times and threading
http://www.dreamincode.net/forums/showtopic45904.htm


I am going to tell you the truth. That is alot of code just to update a Form with the current date/time. I am counting about 35 lines of code in that tutorial.

for me, I seem to normally choose the much simpler way of doing this.

1. put a Timer on the form. it's in the Toolbox
2. open the Properties Window, Enable the Timer(disabled by default) and set it's Interval to 1000ms.
3. double-click on the Timer to create the Tick Event
4. in the Tick Event, put in the following code

csharp

label1.Text = DateTime.Now.ToString();


4 total lines of code.
User is offlineProfile CardPM

Go to the top of the page

zakary
post 6 Aug, 2008 - 06:20 AM
Post #6


D.I.C Regular

Group Icon
Joined: 15 Feb, 2005
Posts: 372



Thanked 4 times

Dream Kudos: 175
My Contributions


QUOTE(eclipsed4utoo @ 6 Aug, 2008 - 09:00 AM) *

I am going to tell you the truth. That is alot of code just to update a Form with the current date/time. I am counting about 35 lines of code in that tutorial.

for me, I seem to normally choose the much simpler way of doing this.

1. put a Timer on the form. it's in the Toolbox
2. open the Properties Window, Enable the Timer(disabled by default) and set it's Interval to 1000ms.
3. double-click on the Timer to create the Tick Event
4. in the Tick Event, put in the following code

csharp

label1.Text = DateTime.Now.ToString();


4 total lines of code.


That tutorial is more that just a simple timer it also has threading in it and it is a good start for someone just learning, so go criticize else where.
User is offlineProfile CardPM

Go to the top of the page

hudacskoa
post 6 Aug, 2008 - 06:52 AM
Post #7


New D.I.C Head

*
Joined: 5 Aug, 2008
Posts: 2

QUOTE(jayman9 @ 5 Aug, 2008 - 08:01 PM) *

Try using a Timer control while updating labels that will display the numbers.

Dream.In.Code has a policy by which we prefer to see a good faith effort on your part before providing source code for homework assignments. Please post the code you have written in an effort to resolve the problem, and our members would be happy to provide some guidance. Be sure to include a description of any errors you are encountering as well.

Please post like this:

Thank you for helping us helping you.


with the System.Windows.Forms.Timer control it works fine.

thank you very much
User is offlineProfile CardPM

Go to the top of the page

jayman9
post 6 Aug, 2008 - 08:47 AM
Post #8


Student of Life

Group Icon
Joined: 26 Dec, 2005
Posts: 6,322



Thanked 22 times

Dream Kudos: 500

Expert In: C#, VB.NET, Java

My Contributions


You are welcome, glad we could be of assistance.
User is online!Profile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 9/6/08 09:30AM

Live C# Help!

C# Tutorials

Reference Sheets

C# Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month