|
-
May 21st, 2006, 07:46 AM
#1
Thread Starter
New Member
StopWatch
i have 2 button(Start & Stop) and i want a timekeeper.Please help me.thanks
-
May 21st, 2006, 08:05 AM
#2
Re: StopWatch
If you are using .NET 2.0 (please specify in future) then you have the Stopwatch class available to you. If you're using an earlier version then I've posted a simple Stopwatch class in the C# CodeBank.
-
Jun 4th, 2006, 11:46 AM
#3
Thread Starter
New Member
Re: StopWatch
thanks brother.now,i want a digital clock but pending.please help me
-
Jun 4th, 2006, 02:53 PM
#4
Re: StopWatch
use a Timer and 3 labels (or one label if you know how to do it)
"I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
My Blog
-
Jun 4th, 2006, 05:31 PM
#5
Re: StopWatch
You still haven't specified which version you're using.
As has been said, use a Windows.Forms.Timer and in its Tick event you update the Text in a Label. If you want it to look even more like a digital clock you can use the LedLabel control in the ElementsEx library in my signature.
-
Jun 4th, 2006, 09:54 PM
#6
Thread Starter
New Member
Re: StopWatch
can you demo ?i using vs2005
-
Jun 4th, 2006, 10:10 PM
#7
Re: StopWatch
Add a Timer to your form in the design Window and set its Interval property to the number of milliseconds you want between updates. Also set its Enabled property to False. Double-click it to create a Tick event handler. In that event handler place the code to set the Label's Text property to whatever it is you want displayed. Whenever you start the StopWatch you call the Start method of the Timer and whenever you stop the StopWatch you call the Stop method of the Timer.
-
Jun 4th, 2006, 10:40 PM
#8
Re: StopWatch
 Originally Posted by jmcilhinney
Add a Timer to your form in the design Window and set its Interval property to the number of milliseconds you want between updates. Also set its Enabled property to False. Double-click it to create a Tick event handler. In that event handler place the code to set the Label's Text property to whatever it is you want displayed. Whenever you start the StopWatch you call the Start method of the Timer and whenever you stop the StopWatch you call the Stop method of the Timer.
That's not a demo, this is "explanation"
"I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
My Blog
-
Jun 4th, 2006, 11:29 PM
#9
Re: StopWatch
That's quite true. How do you demo adding controls in the designer? I'm not going to create a project and post it. Following instructions takes more thought than copying and pasting code and I'm all for that. You learn much more by doing, even if you're doing what someone else tells you to.
-
Jun 5th, 2006, 08:27 AM
#10
Thread Starter
New Member
Re: StopWatch
this problem i had done but i want a stopwatch similar as game minesweeper of microsoft.
-
Jun 5th, 2006, 09:57 AM
#11
Hyperactive Member
Re: StopWatch
jmcilhinney could you also do what you described there in 1.1 Framework?
And I think jmcilhinney explains quite well. The help he has given to me, at first I thought why not create something and send it to me it might be easier, but following the instructions made me learn better. Keep it up and thanks - Jennfer
-
Jun 5th, 2006, 05:44 PM
#12
Re: StopWatch
 Originally Posted by JenniferBabe
jmcilhinney could you also do what you described there in 1.1 Framework?
Absolutely. In VS.NET 2003 you have the advantage that the Timers.Timer component is in the Toolbox by default. For this I'd be inclined to use the Timers.Timer over the Windows.Forms.Timer because if you clear the SynchronizingObject property of the Timers.Timer it will raise its Elapsed events in a worker thread. That means that your stopwatch display will not stutter if the UI thread is busy doing something.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|