[RESOLVED] How to stop timer automatically
Hello Everyone,
I am developing a application in which i need your little help to complete...
i have listbox and have set timer for auto selecting...
i want to stop the timer after selection in liatbox reaches 10...or you can say that after running that timer 10 times....
and after 15 min i wanna that turn on automatically....
finally what i want is :
a timer stops for 15 minutes after running 10 times ..
little help would be appreciated..
thanks in advance.
Re: How to stop timer automatically
Stopping the timer after filling the listbox is easy ... you just monitor the count of items in the listbox in the timer code - when it reaches 10, you set the Timer's .Enabled property to false.
If you want it to turn on the timer after 15 minutes you'll need a 2nd timer that is enabled at the same time as you disable the first one.
When your form loads, set Timer1.Enabled = true, Timer2.Enabled = false. Then, when the code in timer1 determines the listbox is filled, disable Timer1, enable timer2. Timer2 should then count to 15 minutes (however you decide to handle that) then re-enable timer1 and disable itself after re-enabling timer1. Lather, rinse, repeat.
-Max :D
Re: How to stop timer automatically
Hello sir,,,
i got it what u say.....but can u give me the code how to stop after 10 counts..plz..
thanks for ur reply
Re: How to stop timer automatically
Quote:
Originally Posted by
Sumit4Work
Hello sir,,,
i got it what u say.....but can u give me the code how to stop after 10 counts..plz..
thanks for ur reply
Here's an alternate idea. Why don't you write some code (give it a try) then let us help you debug it. You won't learn anything if I just "give" you the code.
-Max :D
Re: How to stop timer automatically
Place a global variable and initialize it to 0. Everytime the TimerTick event is triggered increment your variable by one. Check to see if it reaches 10 and do what Max suggested then
Re: How to stop timer automatically
thanks max..i got it...
i made a label and counts the timer...and then use if label value is # then timer2.start and timer1.stop..
thank you very much sir...
Re: How to stop timer automatically
Quote:
Originally Posted by
Sumit4Work
thanks max..i got it...
i made a label and counts the timer...and then use if label value is # then timer2.start and timer1.stop..
thank you very much sir...
That's the spirit. Glad you worked it out.
-Max :D